Living Museum of Learning

Where real moments become exhibits
← Prev Next β†’
Cloud Meets the Collatz Mystery

Cloud Meets the Collatz Mystery

A bug, a sequence, and the moment mathematics became something he could make a computer explore.

Cloud had struggled with his homework and arrived at class feeling low. His father's code had also confused him. Instead of pushing harder on the homework, Donald changed direction.

They began with a world-famous mathematical mystery: the Collatz conjecture.

The rule was simple:

If a number is even, divide it by 2.
If it is odd, multiply it by 3 and add 1.
Repeat.

Cloud first explored the sequence manually, starting with 9:

9 β†’ 28 β†’ 14 β†’ 7 β†’ 22 β†’ 11 β†’ 34 β†’ 17 β†’ 52 β†’ 26 β†’ ...

He even noticed an important pattern immediately: once a number has already appeared, there is no need to explore its future again.

The hand calculation contained a small bug: Cloud wrote 13 β†’ 39, forgetting the +1.

Then came a second, more interesting bug in his first Python program.

He had written:

if m % 2 == 0:

instead of checking the changing value:

if next % 2 == 0:

The result was spectacular: the numbers kept getting larger and larger.

When Donald found the bug and fixed it, Cloud ran the program starting from 9.

The computer produced the same sequence he had calculated by hand.

Cloud lit up.

The mathematics had crossed from his notebook into the computer.

Cloud discovered that a mathematical rule could become a program.

His first working Collatz explorer used:

% to distinguish even and odd numbers
// to divide
if / else to express the rule
a for loop to repeat the experiment
break to stop when the sequence reached 1

He had not become a self-proclaimed β€œmath lover.”

In fact, he told Donald that he wasn't one.

But perhaps that was because Cloud still did not know what mathematics could be.

Tonight, mathematics was not a worksheet.

It was a mystery.

And Python became his laboratory.

Cloud practiced translating a mathematical rule into an executable algorithm, debugging a program by identifying the wrong variable, and comparing computational output with a manually calculated sequence.

Most importantly, he experienced a powerful cycle:

wonder β†’ experiment β†’ mistake β†’ debugging β†’ discovery

He also spontaneously recognized that repeated numbers do not need to be explored againβ€”a small but genuine glimpse of algorithmic thinking.

Can a simple mathematical rule generate an endless journey?

How do numbers, conditions, and loops become a program?

Because a problem can become much more exciting when you can build a machine to investigate it.