Generates a series of primes numbers in ascending order.
PRIMES(n, "count", "nth", "silent")
n |
- |
An integer, the maximum prime value. The returned series contains prime numbers less than or equal to n. |
"count" |
- |
Optional.
A string. If specified, only return the count of |
"nth" |
- |
Optional.
A string. If specified, only return the nth |
"silent" |
- |
Optional. A string. If specified, operate without status messages. Defaults to "verbose", show status messages. |
PRIMES(pmin, pmax, "count", "nth", "silent")
pmin |
- |
An integer, the minimum prime value. The returned series contains prime numbers greater than or equal to pmin. |
pmax |
- |
An integer, the maximum prime value. The returned series contains primes less than or equal to pmax. |
"count" |
- |
Optional.
A string. If specified, only return the count of |
"nth" |
- |
Optional.
A string. If specified, only return the nth |
"silent" |
- |
Optional. A string. If specified, operate without status messages. Defaults to "verbose", show status messages. |
A series, the prime values less than or equal to n.
W1: primes(10)
W1 contains the series {2, 3, 5, 7}.
W1: primes(10, "count")
returns 4 indicating there are 4 prime values less than or equal to 10.
W1: primes(4, "nth")
returns 7, the fourth prime.
W1: primes(10)
W2: isprime(W1)
W2 contains the series {1, 1, 1, 1}, indicating that all the values of W1 are prime.
W1: primes(10, 20)
W1 contains the series {11, 13, 17, 19}, the primes values between 10 and 20.
W1: primes(10, 20, "count")
returns 4, indicating there are 4 prime values between 10 and 20.
A prime number is a natural number (positive integer) with exactly two divisors, 1 and itself. Thus, 0 and 1 are not prime.
PRIMES uses a segmented sieve of Eratosthenes algorithm with wheel factorization written by Kim Walisch licensed under the MIT License.
https://github.com/kimwalisch/primesieve