Iterating over primes

As one of the main developers of Primes.jl the basic things you are missing for performance are as follows:

  1. Fast isprime checking (look up Baillie–PSW or Miller-Rabin). For an n bit number, these methods are ~O(n^3) as opposed to O(2^n) of trial division
  2. Sieve methods rather than spending time testing whether each number is prime individually, we can compute all the primes up to n in roughly O(n) operations.
4 Likes