Doing this is really simple.

Consider a fraction represented as (numerator) / (denominator). To reduce it to its lowest form, divide both - numerator and denominator - by the GCD (Greatest Common Divisor) of the numerator and the denominator.

To find the GCD, Euclid's algorithm works really fast.

Here's the pseudo-code to find the GCD:

Consider a fraction represented as (numerator) / (denominator). To reduce it to its lowest form, divide both - numerator and denominator - by the GCD (Greatest Common Divisor) of the numerator and the denominator.

To find the GCD, Euclid's algorithm works really fast.

Here's the pseudo-code to find the GCD:

functiongcd(a, b)whileb ≠ 0 t := b b := amodt a := treturna