Function reference · Special functions

nextprime

Returns the smallest prime greater than an integer.

Notation

nextprime(value)

Write it in an expression: nerdamer('nextprime(10)'), or in the Playground.

nerdamer.nextprime

nerdamer.nextprime(value: ExpressionInput): Expression

A method on the default import. Arguments can be strings, as in Notation.

Parameters

value
An integer. The result is always greater than it, even when value is prime.

Returns

The next prime, as an integer.

Examples

The first prime after 10.

nextprime(10)
// → 11
Open in Playground

13 is prime, but the result is strictly greater.

nextprime(13)
// → 17
Open in Playground

Every value below 2 gives 2.

nextprime(-5)
// → 2
Open in Playground

A symbol or a non-integer keeps the call as it is.

nextprime(x)
// → nextprime(x)
Open in Playground

Good to know

  • To split an integer into primes, use factor or pfactor.

JavaScript examples

nerdamer.nextprime(10).text()
// → 11

← Back to Function reference