# ¶Random Number Generator

Whether you need 1 or 1,000 this tool will let you generate a set of random numbers.

## ¶Generate

## ¶Results

## ¶About random numbers

A really important note about computer generated random numbers is that they're not totally random. They're generated by an algorithm that typically uses something called a "seed", and that's usually based on the time on the computer. But, for most cases computer generated randomness is random enough for us.

For times when you need something truly random there are tools that generated seeds from things like atmospheric noise or walls of lava lamps (yes, really).

## ¶Why didn't it work?

Most likely it comes down to the 5,000 limit on this generator. At most this tool will try and generate a random number 5,000 times. It has to stop somewhere so that it doesn't get stuck in an infinite loop and crash your browser. I somewhat arbitrarily picked 5,000 iterations as that limit.

So, you if you ask it to generate 10,000 numbers and it can't, that's why.

You might also run up against this limit if you are asking for a relatively small range without allowing duplicates. If you ask for 100 numbers between 1 and 10 without allowing duplicates, it's just not going to work.

## ¶How to generate random numbers?

If you came here looking for ways to generate a random number in a coding language, we've got you covered.

Let's start with **JavaScript**, since that's what this page is using.

```
let min = 1;
let max = 100;
let num = Math.floor(Math.random() * (max - min + 1)) + min;
```

**Java**

```
int min = 1;
int max = 100;
int num = (int)(Math.random() * (max - min + 1)) + min;
```

Head over to CompSci.rocks if you'd like a little more explanation on how the Java version of this works. There's even some practice problems if you're learning `Math.random()`

for a programming class.

**Python**

```
import random
min = 1
max = 100
num = random.randint(min, max)
```