#include<stdio.h>
int main()
{
int n1,n2,greater,smaller,i=1,lcm;
printf(“Enter two numbers\n”);
scanf(“%d%d”,&n1,&n2);
if(n1>n2)
{
greater=n1;
smaller=n2;
}
else
{
greater=n2;
smaller=n1;
}
while(1)
{
lcm = greater * i;
if((lcm%smaller)==0)
{
printf(“LCM of %d and %d is %d”, n1,n2,lcm);
break;
}
i++;
}
return 0;
} Output Enter two numbers
6
8
LCM of 6 and 8 is 24 For a detailed explanation with the logic