Q23. Write a code to find LCM of two numbers.

LCM :- LCM (Least Common Multiple) of numbers is defined as the smallest possible multiple of two or more numbers.

For Example :-
Input = 6 and 5
Output = 30 is the LCM.
As we can see 30 is the smallest possible multiple of 6 and 5 therefore, 30 is the least common multiple (LCM) of two numbers 6 and 5

Algorithm For LCM

START
Step 1 → Initialize num1 and num2 with positive integers
Step 2 → Store maximum of num1 & num2 to max
Step 3 → Check if max is divisible by num1 and num2
Step 4 → If divisible, Display max as LCM
Step 5 → If not divisible then increase max by 1 and then goto step 3
STOP

Code For LCM

Output

LCM of 5 and 6 is 30

Recommended Programs
Program to find factorial of a number
Program to count number of digits in a number