This type of exercise can be solved using the function : fraction
For any pair of integers a, b with b not zero, the ratio a:b is called a fraction the ratio a:b, it is denoted `a/b`, a is called the numerator and b the denominator.
A fraction is also called a rational number.
To simplify a fraction we start by decomposing the numerator and denominator into a product of prime numbers. When the same number appears in both the numerator and denominator, we can simplify the fraction.
Example : `56/32` = `(2*2*2*7)/(2*2*2*2*2)` = `7/4`
A fraction is said to be irreducible if its numerator and denominator are prime to each other To put a fraction into its irreducible form sous sa forme irréductible, we divide the numerator and denominator by their gcd .
Two fractions are equal if it is possible to go from one to the other by multiplying or dividing the numerator and denominator by the same number.
Simply compare the numerators.
The largest is the one with the smallest numerator.
We return to the case where the denominators are equal by applying the equality condition of a fraction.
These are the calculation techniques that the fraction comparator will use in this example to compare the fractions `19/11` and `13/7`.
The sum of two fractions with the same denominator has the same denominator, so its numerator is equal to the sum of the numerators.
Therefore, we have the formula:`a/k+b/k=(a+b)/k`
The following example : `1/3+4/3` shows how to add two fractions that have the same numeratorr.
We reduce the fractions to the same denominator, to get back to the case of adding fractions with the same denominator.
The difference of two fractions with the same denominator has the same denominator, its numerator is equal to the difference of the numerators.
Therefore, we have the formula:`a/k-b/k=(a-b)/k`
The following example: `4/3-2/3` shows how to subtract two fractions that have the same numerator.
We reduce the fractions to the same denominator, to get back to the case of subtracting fractions with the same denominator.
The product of two fractions is equal to the product of the numerators over the product of the denominators.
`3/4*7/3` = `21/12`
The following example `3/4*7/5` : shows how to multiply two fractions.
Dividing by a fraction is the same as multiplying by the inverse of that fraction, using this rule it is possible to turn a fraction quotient into a fraction product and apply the rules for simplifying a product of fractions.
Example:`(-8/3)/(2/3)` = `-8/3*3/2` = `-8/2` = -4