//最大公约数
public static int getdivisor(int a, int b)
{
while(a!=b)
{
if(a>b)
a=a-b;
else if(a<b)
b=b-a;
}
return b;
}
1.0
//最小公倍数
public static int getmultiple(int a,int b)
{
int n=a*b;
while(a!=b)
{
if(a>b)
a=a-b;
else if(a<b)
b=b-a;
}
return n/b;
}
Java求最大公约数和最小公倍数
猜你喜欢
转载自cm1993.iteye.com/blog/2283715
今日推荐
周排行