#include <stdio.h>
int main()
{
int a,b,c,d,temp,j,hcf;
printf("enter two numbers\n");
scanf("%d%d",&a,&b);
if(a>b)
temp=a;
else
temp=b;
for (j=1; j<=temp; j++)
{
c = a%j;
d = b%j;
if(c==0 && d==0)
hcf=j;
}
printf("\nLCM of %d and %d is %d\n",a,b,a*b/hcf);
return 0;
}
/*Next method*/
ReplyDelete#include
#include
int main()
{
int a,b,big,small,lcm,i;
printf("\n Enter two numbers : \n");
scanf("%d %d",&a,&b);
big=a>b?a:b;
small=a<b?a:b;
for(i=1;;i++)
{
lcm=big*i;
if(lcm%small==0)
break;
}
printf("\n\n\t L.C.M. of %d and %d is %d",a,b,lcm);
return 0;
}