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

How a GCSE in Computer Science can shape your future career

A GCSE in Computer Science opens the door to careers in gaming, robotics, cyber security, and beyond.
Discover how this subject can lead to exciting degrees and future opportunities in the tech world.

29 April 2026

Do we need government AI copyright laws?

AI is transforming creativity — but are we protecting the people behind the art? We explore the UK’s heated debate over AI copyright laws and what they mean for creators and innovation.

8 April 2026

How Do Map Apps Work?

Discover how your map app uses graph theory and clever algorithms to find the fastest route, even before you spot the traffic jam. It’s the smart tech behind every turn and reroute you trust.

What is Chip Binning?

Chip binning is how manufacturers sort silicon chips based on their performance, turning some into high-speed processors and others into more modest models. It’s like baking cookies—some come out perfect, others just good enough.

Meet Dodona: A powerful coding platform built for real classrooms

Discover how Dodona is transforming programming lessons with a powerful, classroom-ready platform built by educators. With the integration of Time2Code, it’s never been easier to deliver engaging, structured coding lessons while saving time and reducing hassle.

Students looking at a hill to climb.

Goals version 2

Until now, the Terms goal has used the Leitner system to determine what students should complete each week. This approach […]

4 April 2026

Differentiation is dead

For decades, teachers were told that differentiation was the golden ticket. If we could just tailor the right task to […]

3 April 2026

It’s not in the mark scheme

Just because it’s not in the mark scheme doesn’t mean it’s wrong — Quicksort proves there are often multiple valid ways to reach the same correct answer.
Understanding the principles behind algorithms matters far more than memorising a single “approved” method.

27 March 2026

Festival Of Computing OCR Fringe Event 2026

The Festival of Computing 2026, co-founded and hosted by Bromsgrove School with AQA as headline sponsor, is the UK’s ultimate […]

24 March 2026