Is there a simple algorithm that can determine if X is prime?

后端 未结 16 1523
离开以前
离开以前 2020-12-01 00:32

I have been trying to work my way through Project Euler, and have noticed a handful of problems ask for you to determine a prime number as part of it.

  1. I kno

16条回答
  •  甜味超标
    2020-12-01 00:56

    I'd recommend Fermat's primality test. It is a probabilistic test, but it is correct surprisingly often. And it is incredibly fast when compared with the sieve.

提交回复
热议问题