Как вывести сокращённую дробь в программе С#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Task;
using Result;
namespace Quiz
{
class Вычисления
{
public string ДоВычислений ()
{
int ans, n, d,числ, знам;
ans = 0;
Console.Write("Введите числитель = ");
n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\n");
Console.Write("Введите знаменатель = ");
d = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\n");
Console.Write("Дробь= {0}/{1} ",n,d);
Console.WriteLine("\n");
foreach (Task.Операции p in Task.Task.AllOperation)
{
Console.WriteLine("\n");
Console.WriteLine(p.Operation);
Console.WriteLine("\n");
Console.WriteLine("1. " + p.Answers[0]);
Console.WriteLine("2. " + p.Answers[1]);
Console.Write("Выберите действие > ");
ans = Convert.ToInt32(Console.ReadLine());
int nod=1;
if (nod != 0)
{
числ = nod;
знам = nod;
}
else знам = 0;
}
return Result.Ответы. GetMessage(ans);
}
static int Nod(int n, int d)
{
int temp;
n = Math.Abs(n);
d = Math.Abs(d);
while (d != 0 && n != 0)
{
if (n % d > 0) {
temp = n;
n = d;
d = temp % d;
} else break;
}
if (d != 0 && n != 0) return d;
else return 0;
}
}
}