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

natural

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

Return a natural number.

range: 0 to 9007199254740991

randBox.natural(); => 125019392395

Can optionally provide min and max.

randBox.natural({min: 1, max: 20}); => 14

Can optionally provide numbers you wish to exclude.

randBox.natural({min: 1, max: 5, exclude: [1, 3]}); => 2

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

// Specific case 1 <= random number <= 3 // General case min <= random number <= max

Natural Number on Wikipediaย 

Last updated on: