experiments/csharp/E037-FractionReduce/Program.cs

17 lines
333 B
C#
Raw Normal View History

2024-05-04 21:16:52 +01:00
Console.WriteLine(Reduction(7, 16));
return;
static string Reduction(int numerator, int denominator)
{
for (var i = 10; i > 1; i--)
{
while (numerator % i == 0 && denominator % i == 0)
{
numerator /= i;
denominator /= i;
}
}
return $"{numerator}/{denominator}";
}