#include
#include
int lcm(int,int);
int main(void)
{
int a,b,c;
printf("Enter two positive integers:\n");
scanf ("%d%d",&a,&b);
c=a*b/lcm(a,b);
printf("Least Common Multiple of %d and %d is:%d\n",a,b,c);
getch();
return 0;
}
int lcm(int a,int b)
{
int c,greater,smaller;
if (a>b)
greater=a,smaller=b;
else
greater=b,smaller=a;
if(smaller==0)
return greater;
else
c=lcm(smaller,greater%smaller);
return c;
}
No comments:
Post a Comment