I've all prime numbers that can be stored in 32bit unsigned int
and I want to use them to generate some 64bit prime numbers. using trial division is too slow even with optimizations in logic and compilation.
I'm trying to modify Sieve of Eratosthenes to work with the predefined list, as follow:
- in array A from 2 to 4294967291
- in array B from 2^32 to X inc by 1
- find C which is first multiple of current prime.
- from C mark and jump by current prime till X.
- go to 1.
The problem is step 3 which use modulus to find the prime multiple, such operation is the reason i didn't use trail division.
Is there any better way to implement step 3 or the whole algorithm.
thank you.