#include <stdio.h>
int main(void){
int x,y,i,j,lcm; //lcm 就是 lowest common multiple 最小公倍數
printf("enter 2 numbers:\n");
scanf("%d %d",&x,&y);
if(x>y)
{i=x;
j=y;}
if(x<y)
{i=y;
j=x;}
for(lcm=i;;lcm++)
{
if((lcm%i==0)&&(lcm%j==0)) break;
}
printf("The lcm of %d and %d is %d.",x,y,lcm);
return 0;
}
|