matho-primes (1) - Linux Manuals

matho-primes: generate consecutive prime numbers


matho-primes - generate consecutive prime numbers


matho-primes [start [stop]] ["twin"] ["pal" [base]]
matho-primes [-t] [-p base] [start [stop]]


This command line utility is optionally part of the mathomatic(1) package. It quickly computes any number of consecutive prime numbers using a windowing, memory efficient sieve of Eratosthenes algorithm, dumping them to standard output. They are displayed one prime per line in ascending order, unless the "twin" option is specified, which displays only twin primes, two primes per line.

Generates up to 18 decimal digit primes, or whatever is the number of digits of precision for a long double in the C compiler used to compile this utility.

A range may be specified on the command line, otherwise the starting number and the number of primes to output is prompted for. The range is start to stop inclusive, and stop must be greater than or equal to start.

If the "-t" or "twin" option is specified on the command line, only twin primes will be displayed. Twin primes are two primes that differ in value by 2. Each twin pair is displayed together on the same line separated by a space character.

If the "-p" or "pal" option is specified on the command line, only palindromic primes are displayed. Palindromes are symmetrical, they read exactly the same forward and backward. The palindrome number base may be specified, the default is base 10. The base can be any integer greater than 1.


George Gesslein II (gesslein [at]


mathomatic(1), primorial(1), matho-mult(1), matho-sum(1)