最大公约数与最小公倍数

Roman edited 3 年,8 月前

int GCD(int a, int b)
{
int temp;
while (a % b != 0){
temp = a % b;
a = b;
b = temp;
}
return b;
}
int LCM(int a, int b)
{
return a * b / GCD(a,b);
}

Comments