Ultra Calculator
    Games

    Random Number Generator

    Enter the lowest and highest numbers, how many you want and whether a number may come up more than once. Each pick uses your browser's random number generator to choose a whole number in that range, both ends included, and the result appears as soon as the fields are filled in.

    Last updated by Ultra Calculator

    Random Number

    How to calculate it

    n = min + floor(r × (max − min + 1))
    n
    the number picked
    min
    the lowest number
    max
    the highest number
    r
    a random fraction from 0 up to, but not including, 1, supplied by your browser
    floor
    round down to a whole number

    Without repeats, each pick is made from the numbers not yet drawn (a Fisher-Yates shuffle), so no number can appear twice.

    Worked example

    Pick a number from 1 to 10

    One whole number from 1 to 10. Both ends are included, so there are ten possible results, and any of them can come up.

    You enter
    Lowest number1
    Highest number10
    How many numbers1
    Allow repeatsNo, every number is different
    The calculator returns
    Result5
    Whole numbers in the range10

    How to use this calculator

    1. Enter the Lowest number and the Highest number. Both are included, so a draw from 1 to 10 can give 1 or 10.
    2. Set How many numbers you want, from 1 to 1,000.
    3. Choose Allow repeats: No makes every number different, Yes lets a number come up more than once.
    4. Read the Result in the order drawn. When you pick more than one number, the sorted list appears underneath.
    5. Press Generate again for a fresh draw with the same settings.

    Frequently asked questions

    How do I pick a random number between 1 and 100?

    Enter 1 as the lowest number, 100 as the highest and 1 under How many numbers. Both ends are included, so there are 100 possible results and 1 and 100 can each come up.

    Can I generate random numbers without repeats?

    Yes. Set Allow repeats to No and every number in the result will be different. You can't ask for more numbers than the range holds: 1 to 10 without repeats gives at most ten, and the calculator shows a warning instead of a new result if you ask for more.

    Are the numbers truly random?

    They come from your browser's built-in generator, Math.random, which is pseudo-random: an algorithm produces the numbers from a starting value the browser chooses. That suits games, classroom activities and deciding who goes first. MDN's documentation says it is not cryptographically secure, so don't use it for passwords, codes or anything else where security matters.

    Can the range include zero or negative numbers?

    Yes. The lowest and highest numbers can each be anything from -1,000,000,000 to 1,000,000,000, including 0, as long as the lowest is not more than the highest. A range from -5 to 5 holds 11 whole numbers.

    What are the chances of getting a particular number?

    The calculator spreads the browser's random fraction evenly across the range, so with repeats allowed the calculator models each pick as giving every number a 1 in N chance, where N is the figure under Whole numbers in the range. Without repeats, every number not yet drawn has an equal chance on the next pick, and that chance rises as the pool shrinks.

    Learn more

    Pseudo-random numbers

    A computer follows instructions, so a browser makes random numbers with an algorithm that produces a long run of values with no pattern you could spot by eye. The browser picks the starting point and you can't set or repeat it. MDN describes Math.random as returning a fraction from 0 up to 1 with an approximately uniform distribution.

    Both ends count

    A range from 1 to 6 holds six whole numbers, not five. In general it holds highest minus lowest plus 1, which is the figure shown under Whole numbers in the range.

    With and without repeats

    With repeats, every pick starts again from the full range, like rolling a die again. Without repeats, a number leaves the pool once it is drawn, like pulling raffle tickets out of a hat without putting them back.

    • Picking the winning ticket in a school, club or office raffle
    • Deciding who goes first in a game
    • Putting a list of names in a random order: number them, then draw every number without repeats
    • Choosing random questions, pages or exercises to revise
    • Generating test values for a spreadsheet or a maths lesson

    Asking for more different numbers than the range holds

    Without repeats, 1 to 10 can only give ten numbers. Widen the range or set Allow repeats to Yes.

    Forgetting that both ends are included

    A draw from 1 to 10 has ten possible results. If 10 should not be possible, set the highest number to 9.

    Reading the sorted list as the draw order

    When order matters, such as a running order or prize places, use the Result line. The sorted list is only there to make the numbers easier to check.

    Using it for passwords or security codes

    Math.random is not cryptographically secure, according to MDN. Use a password manager, or a generator built on the browser's crypto.getRandomValues, for anything that needs to stay secret.

    Methodology and sources

    Each number comes from your browser's Math.random function, which returns a pseudo-random fraction from 0 up to 1; MDN describes its spread as approximately uniform. The calculator multiplies that fraction by the size of your range, rounds down and adds the lowest number, so every result is a whole number from the lowest to the highest inclusive. Without repeats it runs a Fisher-Yates shuffle, taking each pick from the numbers not yet drawn. Nothing is weighted or adjusted afterwards. Math.random is not cryptographically secure, so don't use these numbers for passwords, security codes or a draw whose result someone may need to verify.