how do random numbers on computers work?

1.39K views

For example, is there a formula for a random number?

In: 47

75 Answers

Anonymous 0 Comments

Yes, basically. What you usually use on a computer is called a pseudorandom number. You have an equation that produces unpredictable results from 0 to 1, and you feed it a seed number (often the current time, or the output of your last random number). This is *good enough* for most purposes, and has the advantage that if you need to test something you can use the same seed number and get repeatable results.

If you need a genuinely random number, you use a [hardware random number generator](https://en.wikipedia.org/wiki/Hardware_random_number_generator). These basically measure something unpredictable about the physical world, and use that measurement as the random number. For example, you could use a radio antenna to take a sample of static. Or, [Cloudflare uses a webcam pointed at a bank of 100 lava lamps](https://www.cloudflare.com/learning/ssl/lava-lamp-encryption/).

You are viewing 1 out of 75 answers, click here to view all answers.