As one of the main developers of Primes.jl the basic things you are missing for performance are as follows:
- Fast
isprimechecking (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 - Sieve methods rather than spending time testing whether each number is prime individually, we can compute all the primes up to
nin roughly O(n) operations.