Input: A = 10, Lcm = 10, Hcf = 50. Output: B = 50 Input: A = 5, Lcm = 25, Hcf = 4. Output: B = 20
A * B = LCM * HCF
B = (LCM * HCF)/A
Example : A = 15, B = 12
HCF = 3, LCM = 60
We can see that 3 * 60 = 15 * 12.
How does this formula work?
Since HCF divides both the numbers, let.
A = HCF * x
B = HCF * y
Note that x and y are not common factors, so LCM must include HCF, x and y.
So we can conclude.
LCM = HCF * x * y
So LCM * HCF = HCF * x * y * HCF which is equal to A * B
Below is the implementation of the above approach:
B = 1
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.
- Sum of LCM(1, n), LCM(2, n), LCM(3, n), ... , LCM(n, n)
- Count the number of subsequences of length k having equal LCM and HCF
- LCM and HCF of fractions
- Given GCD G and LCM L, find number of possible pairs (a, b)
- Program to find GCD or HCF of two numbers
- Program to find HCF iteratively
- Program to find HCF (Highest Common Factor) of 2 Numbers
- Program to find GCD or HCF of two numbers using Middle School Procedure
- Find HCF of two numbers without using recursion or Euclidean algorithm
- Find any pair with given GCD and LCM
- Find two numbers with given sum and maximum possible LCM
- Find the ratio of LCM to GCD of a given Array
- LCM of digits of a given number
- HCF of array of fractions (or rational numbers)
- Find the other end point of a line with given one end and mid
- Program to find LCM of two numbers
- Find LCM of rational numbers
- Program to find LCM of 2 numbers without using GCD
- Find three integers less than or equal to N such that their LCM is maximum
- Program to find LCM of two Fibonnaci Numbers
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.