Skip to Content
๐ŸŽฒ Welcome to RandBox - Powerful JavaScript Random Data Generation Library! Learn More

prime

// usage randBox.prime() randBox.prime({ min: 1, max: 20 })

Return a prime number.

default range: 0 to 10000

randBox.prime(); => 929

Can optionally provide min and max.

randBox.prime({min: 1, max: 20}); => 13

These are inclusive, so they are included in the range. This means randBox.prime({min: 2, max: 5}); would return either 2, 3, or 5 or:

// Specific case 2 <= random number <= 5 // General case min <= random number <= max

Prime Number on Wikipediaย 

Last updated on: