public Boolean rabin_miller(double num) { int s = num.subtract(BigInteger.ONE); int t = 0;
BigInteger[] bis = s.divideAndRemainder(two); while(bis[1].compareTo(BigInteger.ZERO)== 0){
s = (double) (s.divide(two));
t += 1;
} for (int i = 0; i < 5; i++) { int max = num.subtract(BigInteger.ONE); int min = 2;
Random random = new Random(); double a = (double) random.nextInt(max)%(max-min+1) + min; int v = (int) Math.pow(a, s, num); if(v != 1){
i = 0; while(v != (num.subtract(one))) { if(i == t - 1) return false; else{
i = i + 1;
v = (v ** 2) % num;
}
}
} return true;
}
}
添加回答
举报
0/150
提交
取消