1.gcd
public static int gcd(int x,int y)
{
if(y==0)
return x;
return gcd(y,x%y);
}
2.lcm
public static int lcm(int x,int y)
{
return x*y/gcd(x,y);
}
洛谷P1029 两个数的乘积等于这两个数的最大公倍数和最小公倍数的乘积
3.判断质数
public static boolean isPrime(int x)
{
if(x==1)
return false;
for(int i=2;i<x;i++){
if(x%i==0)
return false;
}
return true;
}