Random Number Generator

Generate random numbers within a range. Supports multiple numbers with or without duplicates.

Source: National Lottery — Lotto

Konstantin Iakovlev

By Konstantin Iakovlev · Founder, Calks.uk

Last updated: · Verified against HMRC and GOV.UK 2026/27 rates

Disclaimer

This calculator is provided for informational purposes only and should not be considered as financial or tax advice. All calculations are performed locally in your browser — no personal data is collected or sent to our servers. Rates and thresholds are sourced from HMRC and GOV.UK and are updated for the current tax year. Always verify results with HMRC or consult a qualified professional before making financial decisions.

How It Works

This tool generates random numbers within a range you specify. It uses a cryptographically secure pseudorandom number generator (CSPRNG) to ensure results are fair and unbiased. You can generate a single number or a set of multiple numbers, with or without repetition.

Common uses include raffle draws, lottery number selection, random sampling for surveys, assigning random groups and settling decisions fairly. The generator can also produce random dice rolls, coin flips and card draws with correct probability distributions.

True random vs pseudo-random. Math.random() in browsers uses pseudo-random algorithms (xorshift128+ or similar). Sufficient for games, raffles, statistical sampling — but predictable if seed known. For cryptography: crypto.getRandomValues() — draws from OS entropy (mouse movements, thermal noise). True random: physical processes (radioactive decay, quantum sources). ERNIE (Premium Bonds) used valves originally; now semiconductors for ~50 million numbers/month.

Fair sampling in random ranges. Naive Math.random() × N + 1, floor: uniform distribution for most ranges but tiny modulo bias for very large N. For under 2^32: bias negligible. Exact uniform: rejection sampling — generate full 32-bit ints, discard those above largest multiple of range. UK random jury selection: computerised since 1974 (replaced manual property-qualified system).

UK lottery odds. National Lottery Lotto (6/59): 1 in 45,057,474 jackpot; 1 in 9.3 any prize. EuroMillions (5/50 + 2/12): 1 in 139,838,160 jackpot. Set for Life (5/47 + 1/10): 1 in 15,339,390 top prize. Random selection avoids clusters humans pick — if you win, less likely to split. Lottery winnings tax-free (gambling); interest on winnings IS taxable. Avoid common patterns: birthdays cluster 1-31; many pick 7, 11, 13, 'lucky' numbers.

Cryptographic randomness use cases. Use crypto.getRandomValues() (not Math.random) for: password generators (each char from 70-94 char pool); 2FA backup codes; session tokens; CSRF tokens; encryption nonces; UUID v4 generation; salts for password hashing. UK ICO and NCSC require CSPRNG (Cryptographically Secure Pseudo-Random Number Generator) for personal data systems. All modern browsers support since 2014. Math.random is WEAK security — outputs can be reverse-engineered.

Random number applications. Statistical sampling (polling, market research): random selection minimises bias. Computer games: enemy AI behaviour, loot drops. Music shuffle algorithms: 'random' is rarely truly random — Spotify uses weighted shuffle (less repetition per artist). A/B testing: random assignment to variant A or B. Drug trials: double-blind randomisation crucial for valid results. Cryptocurrency mining: 'lottery' for finding valid block hash. UK MoD CHACR: published research on military uses of high-quality random number generators.

Example: Generating lottery numbers

  1. Range: 1 to 59 (UK Lotto)
  2. Quantity: 6 numbers, no repeats
  3. Result: e.g. 7, 14, 22, 35, 41, 53
  4. Each draw is independent and equally likely

Source: National Lottery — Lotto

Frequently Asked Questions

True random vs pseudo-random — what JavaScript uses.
Math.random() in browsers uses pseudo-random algorithms (xorshift128+ or similar). Sufficient for games, raffles and statistical sampling — but predictable if seed is known. For cryptography, use crypto.getRandomValues() — draws from OS entropy (mouse movements, thermal noise). True random comes from physical processes: radioactive decay (random.org uses atmospheric noise), quantum sources (QRNG), or thermal/electronic noise. ERNIE (Premium Bonds) used valves originally; now uses semiconductors for ~50 million numbers/month.
Fair sampling — avoiding bias in small ranges.
Naive Math.random() × N + 1, floor: gives uniform distribution for most ranges but has tiny modulo bias for very large N. For ranges under 2^32, bias is negligible. For exact uniform: use rejection sampling — generate full 32-bit ints, discard those above largest multiple of range. UK random selection in juries: uses computerised random selection from electoral register since 1974, replaced manual property-qualified system.
UK lottery odds — single random pick.
Random number generators don't improve lottery odds — they just avoid clusters humans pick. National Lottery Lotto (6/59): odds 1 in 45,057,474 of jackpot, 1 in 9.3 of any prize. EuroMillions (5/50 + 2/12): 1 in 139,838,160 jackpot. Avoid common patterns: birthdays cluster 1-31; many people pick 7, 11, 13, lucky numbers. Random selection means if you win, less likely to split. Set for Life (5/47 + 1/10): 1 in 15,339,390 top prize. Lottery is taxed: prizes are tax-free (gambling), but interest on winnings IS taxable.
Cryptographically secure use cases.
Use crypto.getRandomValues() (not Math.random) for: password generators (each char from 70-94 char pool); 2FA backup codes; session tokens; CSRF tokens; encryption nonces; UUID v4 generation; salts for password hashing. UK ICO and NCSC require CSPRNG for personal data systems. Browser support: all modern browsers since 2014. Avoid Math.random for ANYTHING security-sensitive — even seemingly random outputs can be reverse-engineered to find seed.