Math calculator

Free random number generator calculator

Generate random numbers between any two values — enter a minimum and maximum to get an instant random result, updated live, as you type.

InputsLive
Minimum
Maximum
How many numbers?
Between 1 and 20 numbers.
Result
Random numbers
18, 35, 99, 2, 99
5 numbers between 1 and 100
Min1
Max100
Count5
Sum253

Uses JavaScript Math.random() (pseudo-random, not cryptographically secure). For security-sensitive use cases, use window.crypto.getRandomValues().

Results are estimates. Consult a professional.

How it's calculated

How the random number generator works

This generator produces uniformly distributed random integers in any range you specify. Each number in the range has an equal probability of being selected, and consecutive results are statistically independent. Under the hood it uses JavaScript's Math.random(), which produces a pseudo-random float in [0, 1), scaled and floored into your target range.

Random integer in [min, max]: floor(Math.random() × (max min + 1)) + min
Probability of each value: 1 ÷ (max min + 1)
Range count: max min + 1 possible outcomes
MDN Web Docs — Math.random()
Example

Worked example: simulating a die roll

Example: random integer from 1 to 6

A board game player needs to simulate a six-sided die roll — a random integer between 1 and 6, with each face equally likely (probability 1/6 ≈ 16.7%).

min = 1, max = 6
range = 6 1 + 1 = 6 possible outcomes
result = floor(Math.random() × 6) + 1
each value (1, 2, 3, 4, 5, 6) has exactly 1/6 probability
1 in 6 chance
Every face has an equal 16.7% probability — the same as a fair physical die. Use the generator above and press again for a new roll.
Quick reference

Common random number generation scenarios

Different scenarios call for different ranges. This table maps everyday use cases to the min–max settings you need.

Use caseMinMaxOutcomes
Six-sided die166
Twenty-sided die (D20)12020
Coin flip (0=tails, 1=heads)012
Random percentage (whole %)1100100
4-digit PIN0999910,000
Lottery pick (1–49)14949
Random month11212
Shuffle tiebreaker (2 people)122

Each integer in the range has equal probability = 1 ÷ (max − min + 1).

Practical tips

Tips for using random numbers effectively

Pseudo-random number generators are excellent for everyday use but have specific limitations worth knowing.

  • Generate multiple at once for draws — if you need to pick 5 unique lottery numbers, generate one at a time and skip repeats, or use the multi-draw mode to get a non-repeating set.
  • Do not use Math.random() for cryptography — for password generation, tokens, or security keys, use window.crypto.getRandomValues() which draws from the operating system's cryptographic entropy source.
  • Seed reproducibility — Math.random() cannot be seeded in browsers; if you need reproducible random sequences (e.g., for simulations), use a seedable PRNG library such as seedrandom.js.
  • True randomness requires hardware — software PRNGs are deterministic given a seed; physical randomness (radioactive decay, atmospheric noise) is available via services like random.org.
  • Repeat a draw to check distribution — run 1,000 draws and count how often each value appears; a fair generator should produce each value roughly equally.
Accuracy & limits

Accuracy and limitations

Math.random() produces a pseudo-random sequence using a deterministic algorithm (xorshift128+ in V8) seeded at startup. For everyday tasks — games, sampling, random assignments, simulations — it is statistically indistinguishable from true randomness and passes standard tests (TestU01, Dieharder). However, it is not cryptographically secure: an attacker who observes enough outputs could predict future values. For security-sensitive applications, always use the Web Crypto API (window.crypto.getRandomValues). The formula also assumes integers only; for random floats or non-uniform distributions, additional transformations are needed.

Glossary

Key terms

An algorithm that produces number sequences that appear random but are fully determined by an initial seed value.
A distribution where every outcome in the range is equally likely. Rolling a fair die produces a discrete uniform distribution over {1, 2, 3, 4, 5, 6}.
JavaScript's built-in PRNG, returning a float in [0, 1). Not cryptographically secure.
Randomness derived from unpredictable physical entropy (OS-level), suitable for passwords and security keys. In browsers: window.crypto.getRandomValues().
The initial value fed into a PRNG. The same seed always produces the same sequence. Math.random() is auto-seeded and cannot be set manually in browsers.
A range [min, max] where both endpoints can appear in the output. The formula floor(Math.random() × (max − min + 1)) + min produces this.
About

About this calculator

Part of our math calculators suite — explore all calculators.

Questions

Frequently asked questions about the free random number generator calculator

A random number generator calculator is a free online tool that helps you generate random integers in a range. Math.random() scaled to [min, max]. It runs entirely in your browser with instant results and no sign-up.
JavaScript double-precision floating-point — accurate to about 15-17 significant digits. For arbitrary precision, use the Big Number calculator.
The statistics calculator computes population variance (divides by n). For sample variance, multiply variance by n/(n-1).

Want a calculator built for your business?

Customize any of our 400+ tools to match your brand, or commission a new one tailored to how your business actually calculates — pricing, payroll, quotes, anything. Deployed on your domain, math runs in your visitors' browsers.