Given a fraction in form of a/b where a & b are positive integers. Find ΔX such that when it is added to numerator as well as denominator of given fraction it will result into a new Ir-reducible fraction c/d.
Input : a = 4, b = 10, c = 1, d = 2 Output : ΔX = 2 Explanation : (a + ΔX)/(b + ΔX) = (4 + 2) / (10 + 2) = 6/12 = 1/2 = c/d Input : a = 4, b = 10, c = 2, d = 5 Output : ΔX = 0 Explanation : (a + ΔX) / (b + ΔX) = (4) / (10) = 2 / 5 = c/d
To solve this type of problem rather than implementing just a programming approach we have to do a little of mathematics. mathematics just necessary is as:
As per question we have to find ΔX such that: => (a + ΔX) / (b + ΔX) = c / d => ad + dΔX = bc + cΔX => dΔX - cΔX = bc - ad => ΔX (d - c) = bc -ad => ΔX = (bc - ad) / (d - c)
So, in a way to finding ΔX we have to only calculate .
ΔX = 6
- Largest proper fraction with sum of numerator and denominator equal to a given number
- Convert Binary fraction to Decimal
- Convert decimal fraction to binary number
- Find Recurring Sequence in a Fraction
- Fraction module in Python
- First occurrence of a digit in a given fraction
- Greedy Algorithm for Egyptian Fraction
- Reduce the fraction to its lowest form
- Expressing a fraction as a natural number under modulo 'm'
- Maximum rational number (or fraction) from an array
- as_integer_ratio() in Python for reduced fraction of a given rational
- Print first N terms of series (0.25, 0.5, 0.75, ...) in fraction representation
- Represent the fraction of two numbers in the string format
- Find amount to be added to achieve target ratio in a given mixture
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.
Improved By : manishshaw1