01 #include<stdio.h>
02
03 int lcm(int,int);
04
05 int main()
06 {
07 int x,y=1;
08
09 printf("Enter Numbers to find LCM ( press 0 to exit) : ");
10
11 while(1)
12 {
13 scanf("%d",&x);
14
15 if(x<1)
16 break;
17 else if(x>y)
18 y = lcm(x,y);
19 else
20 y = lcm(y,x);
21 }
22
23 printf("LCM is %d",y);
24
25 return 0;
26 }
27
28 int lcm(int x,int y)
29 {
30 int temp = x;
31
32 while(1)
33 {
34 if(temp % y == 0 && temp % x == 0)
35 break;
36 temp++;
37 }
38 return temp;
39 }
OUTPUT :
Enter numbers to find LCM (press 0 to exit) :
10
15
20
0
LCM is 60