//求最大公約數,輾轉相除法
unsigned gcd(unsigned x, unsigned y)
{
unsigned temp;
if (x < y){
temp = y;
y = x;
x = temp;
}
while (y != 0)
{
temp = x%y;
x = y;
y = temp;
}
return x;
}
//求最小公倍數
unsigned lcm(unsigned x, unsigned y)
{
unsigned temp;
unsigned result = x*y;
if (x < y){
temp = y;
y = x;
x = temp;
}
while (y != 0)
{
temp = x%y;
x = y;
y = temp;
}
return result/x;
}