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
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Find ΔX which is added to numerator and denominator both of fraction (a/b) to convert it to another fraction (c/d)
- Build Lowest Number by Removing n digits from a given number
- Steps to reduce N to zero by subtracting its most significant digit at every step
- Minimum replacement of pairs by their LCM required to reduce given array to its LCM
- Reduce a given number to form a key by the given operations
- Greedy Algorithm for Egyptian Fraction
- Largest proper fraction with sum of numerator and denominator equal to a given number
- First occurrence of a digit in a given fraction
- Maximum rational number (or fraction) from an array
- Expressing a fraction as a natural number under modulo 'm'
- Find the Nth digit in the proper fraction of two numbers
- Find N fractions that sum upto a given fraction N/D
- Max count of unique ratio/fraction pairs in given arrays
- Convert given Decimal number into an irreducible Fraction
- Convert Binary fraction to Decimal
- Find Recurring Sequence in a Fraction
- Represent the fraction of two numbers in the string format
- Convert given Float value to equivalent Fraction
- Find N numbers such that a number and its reverse are divisible by sum of its digits
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.