next_prime: Find the Next and Previous Prime Numbers

View source: R/RcppExports.R

next_primeR 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

Ironholds/primes documentation built on Feb. 1, 2024, 1:26 a.m.