The goal is to efficiently compute the
One second to find the BILLIONth PRIME
Note
We use the (awful, self-inflicted) convention that
Usage
All of the algorithms can be compiled with
make output/bin/${algo}.outfor an appropriate value of ${algo} (see below).
Once you have successfully built a binary, the usage is quite straightforward: to compute
./output/bin/${algo}.out $n
To benchmark an algorithm, use the provided script:
# to generate benchmark data ./scripts/bench.py ./output/bin/${algo}.out -o benchmark.data
Tip
Consult the Software Requirements to obtain the necessary binaries, or configure which binaries to use.
Algorithms
| Strategy | Algorithm | Target (output/bin/) |
Runtime |
|---|---|---|---|
| Iterate | *-iterate.out |
||
| Naïve | naive-iterate.out |
||
| Square-root | sqrt-iterate.out |
||
| Miller-Rabin | miller-rabin-iterate.out |
||
| Sieve | sieve-*.out |
||
| Sieve of Eratosthenes | sieve-erat-sqrt.out |
||
| Segmented Sieve of Eratosthenes | sieve-erat-segm.out |
||
| Sieve of Pritchard | sieve-pritchard.out |
||
| Wheel-factorised Segmented Sieve of Eratosthenes | sieve-erat-wheel.out |
||
| Legendre's formula | sieve-legendre.out |
🤷1 |
-
🤷 ↩
