// Compiler : Dev-C++ 4.9.9.2
#include<stdio.h>
int lcm(int, int);
int main()
{
int a,b=1;
printf("\t\t\tNumbers Should Be Positive...\n\n\t\t\tTo Quit Press Zero...\n\n\nEnter Numbers : ");
while(1)
{
scanf("%d",&a);
if(a<1)
break;
else if(a>b)
b=lcm(a,b);
else
b=lcm(b,a);
}
printf("LCM : %d",b);
getch();
return 0;
}
int lcm(int a, int b)
{
int temp=a;
while(1)
{
if(temp%b == 0 && temp%a == 0)
break;
temp++;
}
return temp;
}
Post a Comment