How can I test for primality?

前端 未结 16 2217
南方客
南方客 2020-12-05 08:29

I am writing a little library with some prime number related methods. As I\'ve done the groundwork (aka working methods) and now I\'m looking for some optimization. Ofcours

16条回答
  •  无人及你
    2020-12-05 08:40

    Try the sieve of eratosthenes -- that should take out getting the root and floating point issues.

    As for the floor, you will be better served by taking the ceiling.

提交回复
热议问题