printf("ENTER THE NO:");//enter the no. whose lcm is to be find
scanf("%d",&num);
while(num != 1)//in the loop upto number is made 1...
{
if(rem != 0)//if rem is not 0
{
for(i=2;rem!=0;i++)//move loop untill division with num gives u 0 remainder means find the smallest factor of number...which will multily exactly to num...//
rem=num%i;//gives the remainder
}
printf("rem=%d_______%d ---|---%d \n",rem,(i-1),num);//i is taken as (i-1)...bcz at last time ..when condition is false ..i ++mented once more than requiredsmallest common factor..//
num=num/(i-1);//when u get that exactly divisible factor to number...then divide with that number..& put the answer or quotient in num ....
rem=num%(i-1);//also get remainder for that changed value of num again ..if it is 0 or not ...//if it is 0 then it will not enter into if(rem != 0) condition .,,,otherwise enter into that condition to get exactly smallest divisible factor for same number..//.