powered by
Find the next prime numbers or previous prime numbers over a vector.
next_prime(x)prev_prime(x)
prev_prime(x)
An integer vector of prime numbers.
a vector of integers from which to start the search.
Paul Egeler, MS
For prev_prime, if a value is less than or equal to 2, the function will return NA.
prev_prime
NA
next_prime(5) ## [1] 7 prev_prime(5:7) ## [1] 3 5 5
Run the code above in your browser using DataLab