1PRIMESIEVE(1) PRIMESIEVE(1)
2
3
4
6 primesieve - generate prime numbers
7
9 primesieve [START] STOP [OPTION]...
10
12 Generate the prime numbers and/or prime k-tuplets inside [START, STOP]
13 (< 2^64) using the segmented sieve of Eratosthenes. primesieve includes
14 a number of extensions to the sieve of Eratosthenes which significantly
15 improve performance: multiples of small primes are pre-sieved, it uses
16 wheel factorization to skip multiples with small prime factors and it
17 uses the bucket sieve algorithm which improves cache efficiency when
18 sieving > 2^32. primesieve is also multi-threaded, it uses all
19 available CPU cores by default for counting primes and for finding the
20 nth prime.
21
22 The segmented sieve of Eratosthenes has a runtime complexity of O(n log
23 log n) operations and it uses O(n^(1/2)) bits of memory. More
24 specifically primesieve uses 8 bytes per sieving prime, hence its
25 memory usage can be approximated by PrimePi(n^(1/2)) * 8 bytes (per
26 thread).
27
29 -c[NUM+], --count[=NUM+]
30 Count primes and/or prime k-tuplets, 1 <= NUM <= 6. Count primes:
31 -c or --count, count twin primes: -c2 or --count=2, count prime
32 triplets: -c3 or --count=3, ... You can also count primes and prime
33 k-tuplets at the same time, e.g. -c123 counts primes, twin primes
34 and prime triplets.
35
36 --cpu-info
37 Print CPU information: CPU name, frequency, number of cores, cache
38 sizes, ...
39
40 -d, --dist=DIST
41 Sieve the interval [START, START + DIST].
42
43 -h, --help
44 Print this help menu.
45
46 -n, --nth-prime
47 Find the nth prime, e.g. 100 -n finds the 100th prime. If 2 numbers
48 N START are provided finds the nth prime > START, e.g. 2 100 -n
49 finds the 2nd prime > 100.
50
51 --no-status
52 Turn off the progressing status.
53
54 -p[NUM], --print[=NUM]
55 Print primes or prime k-tuplets, 1 <= NUM <= 6. Print primes: -p,
56 print twin primes: -p2, print prime triplets: -p3, ...
57
58 -q, --quiet
59 Quiet mode, prints less output.
60
61 -s, --size=SIZE
62 Set the size of the sieve array in KiB, 16 <= SIZE <= 8192. By
63 default primesieve uses a sieve size that matches your CPU’s L1
64 cache size (per core) or is slightly smaller than your CPU’s L2
65 cache size. This setting is crucial for performance, on exotic CPUs
66 primesieve sometimes fails to determine the CPU’s cache sizes which
67 usually causes a big slowdown. In this case you can get a
68 significant speedup by manually setting the sieve size to your
69 CPU’s L1 or L2 cache size (per core).
70
71 --test
72 Run various sieving tests.
73
74 -t, --threads=NUM
75 Set the number of threads, 1 <= NUM <= CPU cores. By default
76 primesieve uses all available CPU cores for counting primes and for
77 finding the nth prime.
78
79 --time
80 Print the time elapsed in seconds.
81
82 -v, --version
83 Print version and license information.
84
86 primesieve 1000
87 Count the primes <= 1000.
88
89 primesieve 1e6 --print
90 Print the primes <= 10^6.
91
92 primesieve 1e6 --print > primes.txt
93 Store the primes <= 10^6 in a text file.
94
95 primesieve 2^32 --print=2
96 Print the twin primes <= 2^32.
97
98 primesieve 1e16 --dist=1e10 --threads=1
99 Count the primes inside [10^16, 10^16 + 10^10] using a single
100 thread.
101
103 https://github.com/kimwalisch/primesieve
104
106 Kim Walisch <kim.walisch@gmail.com>
107
108
109
110 07/21/2023 PRIMESIEVE(1)