[求助]数学+编程同行来试试
如何判断两个大整数互质,希望有高效一点的办法,最笨的办法我已经有了,就是分解两个数的质因数然后比较,但当整数较大的时候,效率太低,希望有好的办法!
2007-04-18 01:24
2007-04-18 09:05
2007-04-18 10:15
2007-04-18 23:42
2007-04-18 23:50
public class WanHa{
public static void main(String[] args){
System.out.println(isHuZhi(160,852797));
}
public static boolean isHuZhi(int n,int m){
while(m!=0){
int t;
t=m;
m=n%m;
n=t;
}
return n==1;
}
}

2007-04-19 11:55
2007-04-19 21:43
2007-04-21 13:50