nextprime | R Documentation |
Return the next prime number, say p
, with p > n
.
nextprime(n)
n |
Integer |
This function uses probabilistic algorithm to identify primes. For practical purposes, it is adequate, the chance of a composite passing will be extremely small.
A (probably) prime number
Antoine Lucas
The GNU MP Library, see https://gmplib.org
isprime
and its references and examples.
nextprime(14)
## still very fast:
(p <- nextprime(1e7))
## to be really sure { isprime() gives "probably prime" } :
stopifnot(identical(p, factorize(p)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.