Hey kiddo, have you ever wondered how your computer or phone creates random numbers? Well, it's not really possible for a computer to make truly random numbers because they always follow an algorithm – a set of rules or instructions – to make the numbers.
So, what do we do if we need random numbers? We use something called a pseudorandom number generator or PRNG for short. It's a computer program, a bit like a game, that creates numbers that look random but are actually made using a mathematical formula.
Imagine you have a big bag of colored beads, and you want to pick some beads out randomly. But instead of using your hands, you use a machine that shakes the bag, and the beads fall out in a random order. This is a bit like how a PRNG works, except it's way faster and more complicated than you shaking a bag of beads.
The PRNG starts with what we call a "seed" which is an initial number, and then it applies the mathematical formula over and over again, creating a new number each time. The formula is designed so that the new number seems random, but it's not really – it's based on the previous number(s) and the seed.
It's called a "pseudo" random number generator, because the numbers are not truly random – they are predictable if you know the seed and the formula. But for most purposes, they are random enough, so we use them in lots of places where we need random numbers, like generating passwords, simulating games, or cryptography.
So, there you have it, a pseudorandom number generator is like a computer program that creates numbers that look random, but are actually made up of a mathematical formula applied to a seed. It's not truly random, but it's random enough for lots of uses. And that's how computers make random numbers, just like shaking a bag of beads!