在素数判断方法isPrime处不知道该怎么写才能让程序跑出结果而不用等到天长地久...
public static void main(String[] args) {
        long startTime = System.currentTimeMillis();
        BigInteger bigNum = new BigInteger(Long.MAX_VALUE + "");
        bigNum = bigNum.add(BigInteger.ONE);
        int count = 1;
        while (count <= 5) {
            if (isPrime(bigNum)) {
                System.out.println(bigNum);
                count++;
            }
            bigNum = bigNum.add(BigInteger.ONE);
        }
        System.out.println(bigNum.toString());
        long endTime = System.currentTimeMillis();
        System.out.println("Time spent is " +
            (endTime - startTime) + " milliseconds");
    }
    public static boolean isPrime(BigInteger num) {
        
        
        return true;
    }
                            
                                    Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
java的BigInteger有自带的isProbablePrime函数,把参数设置大一点,结果就几乎不会出错。