Generate a list of prime numbers less or equal n, resp. between n1 and n2.

primes(n)

Arguments

n

nonnegative integer greater than 1.

Details

The list of prime numbers up to n is generated using the "sieve of Erasthostenes". This approach is reasonably fast, but may require a lot of main memory when n is large.

In double precision arithmetic integers are represented exactly only up to 2^53 - 1, therefore this is the maximal allowed value.

Value

vector of integers representing prime numbers

See also

Examples