20. Next prime number | R Documentation |
The function nextprime
computes and returns the smallest prime number that is greater than the given number.
nextprime(n, iter = 10, test = "MR")
## Default S3 method:
nextprime(n, iter = 10, test = "MR")
## S3 method for class 'numeric'
nextprime(n, iter = 10, test = "MR")
## S3 method for class 'vli'
nextprime(n, iter = 10, test = "MR")
n |
object of class vli or 32 bits integer |
iter |
number of iterations for testing whether or not each number is prime; numeric |
test |
chosen test: "F" for the Fermat Test, "SS" for the Solovay-Strassen Test or "MR" (by default) for the Miller-Rabin Test; character |
The number of iterations is configurable to set the desired accuracy. A small number of iterations might cause not finding a prime number.
object of class vli
Javier Leiva Cuadrado
n <- as.vli("982234568923564")
x <- nextprime(n)
x
is.prime(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.