Checking if an int is prime more efficiently

前端 未结 11 794
暗喜
暗喜 2020-12-11 04:20

I recently was part of a small java programming competition at my school. My partner and I have just finished our first pure oop class and most of the questions were out of

11条回答
  •  佛祖请我去吃肉
    2020-12-11 04:58

    Using BigInteger.isProbablePrime(certainty) and BigInteger.nextProbablePrime() can significantly cut down the number of cases you need to check quite efficiently

提交回复
热议问题