primesieve function

Function to identify all the primes in a vector of positive integers.

Function to identify all the primes in a vector of positive integers.

This function uses the Sieve of Eratosthenes to find all the primes less than or equal to a given integer.

primesieve(sieved, unsieved)

Arguments

  • sieved: Identified primes (empty vector for initialization)
  • unsieved: Candidate integers

Details

The function assumes that unsieved is a vector of positive integers.

Returns

Returns a vector of primes sieved (selected) from the input vector.

References

Jones, O.D., R. Maillardet, and A.P. Robinson. 2009. An Introduction to Scientific Programming and Simulation, Using R. Chapman And Hall/CRC.

See Also

prime

Examples

primesieve(c(), 2:200)
  • Maintainer: Andrew Robinson
  • License: GPL-3
  • Last published: 2018-05-21

Useful links