Example #1
0
        public static (long, long) ReduceFraction(long numerator, long denominator)
        {
            var greatestCommonDivisor = Maths.CalculateGreatestCommonDivisor(numerator, denominator);

            while (greatestCommonDivisor != 1)
            {
                numerator   = numerator / greatestCommonDivisor;
                denominator = denominator / greatestCommonDivisor;

                greatestCommonDivisor = Maths.CalculateGreatestCommonDivisor(numerator, denominator);
            }

            return(numerator, denominator);
        }