next_prime {primes}R Documentation

Find the Next and Previous Prime Numbers

Description

Find the next prime numbers or previous prime numbers over a vector.

Usage

next_prime(x)

prev_prime(x)

Arguments

x

a vector of integers from which to start the search.

Details

For prev_prime, if a value is less than or equal to 2, the function will return NA.

Value

An integer vector of prime numbers.

Author(s)

Paul Egeler, MS

Examples

next_prime(5)
## [1] 7

prev_prime(5:7)
## [1] 3 5 5

[Package primes version 1.6.0 Index]