Find All Primes Less Than n
Find all prime numbers aka primes less than $n$.
Uses an obvious sieve method and some care, working with logical and integers to be quite fast.
- a (typically positive integer) number.
As the function only uses
n can also be a
vector of numbers.
numeric vector of all prime numbers $<= n$.="" <="" dl="">=>
This function was previously published in the package sfsmisc as
and has been integrated here without logical changes.
(p1 <- Primes(100)) system.time(p1k <- Primes(1000)) # still lightning .. stopifnot(length(p1k) == 168)