Description Usage Arguments Details Value Author(s) Examples
Returns the first n prime numbers (starting at 2)
1 | primes(n)
|
n |
Number prime numbers requested, starting at 2. Maximum is 1e8 or 100,000,000. |
This routine is brute-force and works well for the low primes, i.e.,
for n less than a couple hundred thousand. It is not particularly
efficient for large n. For example, primes(2000) on a
Windows laptop takes approximately 4 seconds,
while primes(5000) takes approximately 30 seconds.
A vector of length n containing prime numbers, in order,
starting at 2. Note that 1 is prime, but is never included here. I.e.,
primes(1) equals c(2).
Trent McDonald
1 2 3 4 5 6 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.