galois.primes

galois.primes(n: int) list[int]

Returns all primes \(p\) for \(p \le n\).

Parameters
n: int

An integer.

Returns

All primes up to and including \(n\). If \(n < 2\), the function returns an empty list.

Notes

This function implements the Sieve of Eratosthenes to efficiently find the primes.

References

Examples

In [1]: galois.primes(19)
Out[1]: [2, 3, 5, 7, 11, 13, 17, 19]

In [2]: galois.primes(20)
Out[2]: [2, 3, 5, 7, 11, 13, 17, 19]

Last update: Apr 21, 2022