# C Program for LCM Of Two Numbers

## Write a C program to find the LCM of two number.

The Least Common Multiple (LCM) is also referred to as the Lowest Common Multiple (LCM) and Least Common Denominator (LCD). The least common multiple, or LCM, is another number that’s useful in solving many math problems. Let’s find the LCM of 12 and 44. One way to find the least common multiple of two numbers is to first list the prime factors of each number.

12 = 2 × 2 × 3

44 = 2 × 2 × 11

A C program can calculate the Lowest Common Multiple (LCM) of two numbersThe method includes finding out the maximum values among two numbers, which are common in both the numbers. The algorithm below will help to calculate the LCM of two numbers. ### Working:-

• Initialize variable check1 and check2.
• Copy the value of n1 and n2 of variable .
• Initialize the while loop where condition is while(check1!=check2).
• In while loop there are two condition If check1<check2
• it is true use this condition check1=check1+n1; .
• Otherwise
check2=check2+n2; .
• Print the value of check1 or check2. ### C Program to calculate LCM of two numbers.

`/** C program to calculate the LCM of two numbers */#include<stdio.h>void lcm_two_no(int,int);int main(){    int n1,n2;     //to take user input n1,n2    printf("Enter two numbers: ");    scanf("%d %d",&n1,&n2);    //call of user define function       lcm_two_no(n1,n2);    return 0;}//function to calculate l.c.mvoid lcm_two_no(int n1,int n2){   int check1,check2;    //to use of duplicity value    check1=n1;    check2=n2;         //to find lcm of number     while(check1!=check2)     {         //for condition true         if(check1< check2              check1=check1+n1;                  //for condition false          else            check2=check2+n2;       }    printf("\nL.C.M of %d and %d is: %d",n1,n2,check1);}`

` `

#### Output

```Enter any two numbers: 12

30

LCM of 12 and 30 is 60.  ```