#include <stdio.h>
int main()
{
long long a,b,c,bigger,smaller,i,j,m,n,k;
printf("輸入兩個整數a b\n");
scanf("%ll %ll",&a,&b);
m=a,n=b;
if (a>=b) bigger=a,smaller=b;
else bigger=b,smaller=a;
c=bigger%smaller;
if (c==0) i=smaller;
else
{
while (c!=0)
{
bigger=smaller;
smaller=c;
c=bigger%smaller;
}
i=c;
}
k=(m*n)/i;
printf("a和b的最小公倍數k=%ll",k);
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/23985.html
標籤:基礎類
下一篇:求解
