View source: R/EratosthenesSieve.R
EratosthenesSieve | R Documentation |
The sieve of Eratosthenes is an ancient method for listing all
prime numbers up to a given value n
.
EratosthenesSieve(n)
n |
a numeric vector consisting of a single positive integer. |
The algorithm scans through the vector from 2 through n, eliminating all multiples of 2, then eliminating all multiples of the next smallest integer (3), and so on, until only the prime numbers less than n remain.
a numeric vector containing all primes less than n.
EratosthenesSieve(100)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.