nextprime(n)
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)))
Run the code above in your browser using DataLab