Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

previousPrime

Previous Prime


Description

Find the next prime below n.

Usage

previousPrime(n)

Arguments

n

natural number.

Details

previousPrime finds the next prime number smaller than n, while nextPrime finds the next prime number below n. In general the previousn prime will occur in the interval [n-1,n-log(n)].

In double precision arithmetic integers are represented exactly only up to 2^53 - 1, therefore this is the maximal allowed value.

Value

Integer.

See Also

Examples

p <- previousPrime(1e+6)  # 999983
isPrime(p)                # TRUE

numbers

Number-Theoretic Functions

v0.8-1
GPL (>= 3)
Authors
Hans Werner Borchers
Initial release
2021-04-11

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.