#include<stdio.h>
void main()
{
int num,num2,num3,a=2,lcm=1;
printf("enter the three numbers\n");
scanf("%d%d%d",&num,&num2,&num3);
while((num!=1)||(num2!=1)||(num3!=1))
if((num%a==0)||(num2%a==0)||(num3%a==0))
{
if(num%a==0)num=num/a;
if(num2%a==0)num2=num2/a;
if(num3%a==0)num3=num3/a;
lcm=lcm*a;
}
else
a++;
printf("\nthe lcm of the three numbers is %d",lcm);
}
No comments:
Post a Comment