Back

How do computers generate random numbers?

29 July 2025

Ah, randomness! It’s everywhere in nature—think dice rolls, quantum physics, or even your cat’s indecision. But when it comes to computers, randomness doesn’t come naturally. Why? Because computers are logical machines, designed to follow precise instructions. So, when we ask for a “random” number, they can’t just pluck one from thin air. Instead, they rely on something called a pseudo-random number generator (PRNG)—essentially, randomness with a script.

How does a pseudo-random number generator work?

Here’s how computers fake randomness step by step:

  1. The magic seed
    The process begins with a “seed” number. This seed could be almost anything—like the exact millisecond from the system clock, the temperature of your CPU, or even the quirky motion of a lava lamp (a trick famously used by Cloudflare for added unpredictability).
  2. Math happens
    Once the seed is set, it’s run through a complex mathematical formula designed to churn out seemingly random results. Picture a blender spinning at full speed, tossing numbers into a chaotic whirl.
  3. Voilà! fake randomness
    Out comes a number that looks completely random. However, if someone knows the original seed and the formula, they can predict the outcome—like a magician pulling the same rabbit from their hat every time.

Can computers create true randomness?

When it comes to security, like encrypting sensitive data, fake randomness isn’t enough. For truly unpredictable results, computers turn to nature for help. They measure chaotic phenomena like radioactive decay, electrical noise, or even the small, unpredictable quirks of daily life. This kind of randomness, called “true randomness,” is far more secure and impossible to predict.

So, while computers don’t naturally do random, they’ve mastered the art of faking it with clever algorithms. But when we need something truly unpredictable, we can rely on the chaos of the natural world. Or, as a simpler alternative, just watch a cat trying to decide whether to go outside.

Want to learn more?

Want to know more, check out The Lesson Hacker’s YouTube video HERE.

For more Lesson Hacker Videos check out the CraignDave YouTube playlist HERE.

Visit our website to explore more cutting-edge tech-transforming news in the computer science world!

Related posts

The biggest curriculum shake-up in a decade – Part 3

Discover what the new Progress 8 and Attainment 8 changes really mean for curriculum planning — and why computing still sits in a tricky spot.
In part three of our CAR breakdown, we unpack the shifts, the challenges, and what they might mean for your department.

28 November 2025

Meet the Team Behind Craig’n’Dave

At Craig’n’Dave, we believe that every mission needs its explorers, problem-solvers, and visionaries. Behind the scenes, our team is working […]

26 November 2025

The biggest curriculum shake-up in a decade – PART 2

From shrinking teaching time to a brand-new GCSE, the latest curriculum review sets the stage for the biggest shake-up in computing education in a decade.

21 November 2025

The biggest curriculum shake-up in a decade

The biggest curriculum shake-up in a decade is here — and computing is right at the centre of it. From a brand-new GCSE to talk of AI qualifications, Craig and Dave break down what it all means for teachers and students.

14 November 2025

Smart Revise Wins Teach Secondary Award for Curriculum Improvement 2025

We are thrilled to announce that Smart Revise has been recognised with the Teach Secondary Award for Curriculum Improvement 2025! […]

10 November 2025

Student kicking a ball into a goal

Introducing Goals: smarter revision, clearer direction

The new Goals feature brings a powerful upgrade to Smart Revise, helping students not only understand their progress but also […]

8 November 2025

High expectations from the first minute

In Computing, every minute counts. Setting high expectations isn’t about demanding work or creating unnecessary pressure—it’s about clarity. It means […]

7 November 2025

High expectations and homework: A culture worth building 

High expectations are often spoken about in education but rarely unpacked in a way that feels practical and actionable. We […]

1 November 2025

What is a code pointer?

Demystifying stars, ampersands and memory mishaps. Pointers in programming can be baffling — all those stars and ampersands, but what do they actually mean?
We break down code pointers using sandwiches, and sticky notes, to make sense of it all.

28 October 2025