Program to Find LCM of two Numbers - ( C Programs )
Example:
Enter two numbers:
10
25
LCM of 10 and 25 is: 50
Explanation:
The program takes two numbers as input from the user. Then, it calculates the LCM of those two numbers using the following formula:
LCM(a,b) = (a*b) / GCD(a,b)
where,
- a and b are the two input numbers.
- GCD(a,b) is the Greatest Common Divisor of a and b.
The program first calculates GCD using the Euclidean algorithm and then uses it to calculate LCM.
Output:
The program displays the LCM of two input numbers.
Use:
This program can be used to calculate the LCM of any two numbers. LCM is a very important concept in mathematics and is used in many real-life applications, such as scheduling tasks in project management, predicting the periodicity of events, and finding the resonance frequency of a system.
Summary:
This program takes two numbers as input from the user, calculates their Greatest Common Divisor using Euclidean algorithm, and then calculates their LCM using the formula LCM(a,b) = (a*b) / GCD(a,b). The calculated LCM is then displayed on the screen.