Simplify a Fraction
How to simplify a fraction?
There are two methods to simplify (or reduce) a fraction.
The method of successive simplifications
This method consists in making successive simplifications by dividing by "small" numbers (2, 3, 5, etc.) until obtaining the irreducible form of the fraction.
Example: how to reduce the fraction `210/378` by the method of successive simplifications?
To find the divisors of a number, please visit this page Find divisors of 210.
We start by dividing 210 and 378 by 2.
We get 105 and 189.
So we have `210/378 = 105/189`
We repeat the operation with 105 and 189.
The latter are divisible by 3 because `105/3 = 35` and `189/3 = 63`.
So we have,
`210/378 = 35/63`
35 and 63 are divisible by 7, `35/7 = 5` and `63/7 = 9`
`210/378 = 5/9`
We get to the end of the process because 5 and 9 have no common divisor other than 1!
The reduced form of fraction `210/378` is `5/9`.
GCD Method
This method is based on GCD (Greatest Common Divisor) i.e. find the GCD of the numerator and denominator and divide them by this GCD.
Example: how to reduce the fraction `210/378` using the GCD method ?
GCD (210,378) = 42. More details on this page How to calculate the GCD of 210 and 378 ?.
To get the reduced fraction, simply divide the numerator and denominator by the GCD ie 42 !
The numerator of the reduced fraction is equal to `210/42` i.e. 5.
The denominator of the reduced fraction is equal to `378/42` i.e. 9.
The same result is obtained as by the first method: `5/9`.
Python
Here is a python function that simplifies a fraction. The input variables "num" and "denom" represent the numerator and denominator of the fraction. For the gcd function, we can either import the python gcd function of the math module or rewrite it as here: Calculate gcd with python.
from math import gcd
def ReduceFraction (num, denom):
d = gcd (num, denom);
num = num//d;
denom = denom//d;
return (num, denom)