Learn R Programming

primes (version 1.6.0)

generate_n_primes: Generate a Sequence of Prime Numbers

Description

Generate a sequence of prime numbers from min to max or generate a vector of the first n primes. Both functions use a fast implementation of the Sieve of Eratosthenes.

Usage

generate_n_primes(n)

generate_primes(min = 2L, max)

Value

An integer vector of prime numbers.

Arguments

n

the number of primes to generate.

min

the lower bound of the sequence.

max

the upper bound of the sequence.

Author

Paul Egeler, MS

Examples

Run this code
generate_primes(max = 12)
## [1]  2  3  5  7 11

generate_n_primes(5)
## [1]  2  3  5  7 11

Run the code above in your browser using DataLab