Given two integers x and y and where x is divisible by y. It can be represented in the form of a fraction x/y. The task is to reduce the fraction to its lowest form.
Input : x = 16, y = 10 Output : x = 8, y = 5 Input : x = 10, y = 8 Output : x = 5, y = 4
Approach: Both of the values x and y will be divisible by their greatest common divisor. So if we divide x and y from the gcd(x, y) then x and y can be reduced to its simplest form.
Below is the implementation of the above approach:
x = 8, y = 5
- Find ΔX which is added to numerator and denominator both of fraction (a/b) to convert it to another fraction (c/d)
- First occurrence of a digit in a given fraction
- Greedy Algorithm for Egyptian Fraction
- Find Recurring Sequence in a Fraction
- Convert Binary fraction to Decimal
- Maximum rational number (or fraction) from an array
- Represent the fraction of two numbers in the string format
- Expressing a fraction as a natural number under modulo 'm'
- Largest proper fraction with sum of numerator and denominator equal to a given number
- Build Lowest Number by Removing n digits from a given number
- Reduce N to 1 with minimum number of given operations
- Find maximum operations to reduce N to 1
- Minimum number of operations required to reduce N to 1
- Reduce the array to a single element with the given operation
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.