Mental Arithmetic for Dummies (Using Binary Numbers)
18 May 2021
Let's imagine a scenario: Your friend just discovered a cool new problem and decides to test you. He asks you the following question:
If you could fold an infinitely large sheet of paper an infinite number of times, after how many folds would it be thick enough to reach the moon?
Seems impossible to calculate in your head, right? It's actually relatively easy. "Relative" is a flexible term, after all. The above situation did happen to me a couple of years ago and I was able to answer it on the spot. My answer wasn't correct, but I came pretty close. The problem is counterintuitive to most because it's an example of exponential scaling. Let's learn how to answer it on the spot.
First, there's a bit of information hidden in the question, namely the thickness of a piece of paper and the distance to the moon. Since we'll be going exponential, you don't need to remember these exactly. As long as they're around the correct order of magnitude, your answer will be accurate enough to blow your friend's mind.
For now, let's assume the thickness of paper () is 0.1 mm (or m) and the distance to the moon () is 400,000 km (or m). We should also note that folding a sheet of paper in half doubles its number of layers. Therefore, folding a sheet times will result in layers.
Time for a little bit of math:
This means that in order for a stack of paper (folded x times) to reach the moon, it needs to have 4 trillion layers. From here, you could grab a calculator and learn that , but that would be boring. Let's see how to do it the cool way.
PS. Don't worry if you mess this part up a bit. Your friend will still be impressed if you give them any answer between 30 and 50. In other words, errors made until this point are mostly harmless. Here's where the real magic comes in.
Harnessing the Arcane Power of Binary Numbers
That was a lot of numbers to juggle in your head, so let's take a step back and see what makes binary numbers so cool.
First, what are "binary numbers"? In this article, I've used the term as a vague buzzword (bad!). The term "binary number" may in fact be technically meaningless, but can be used to describe the binary representation of a real number. This is what enables computer science, computer engineering, and computers in general to exist in their current form. Here I use the term instead to mean "powers of two", which is a different term, albeit closely related.
So what are "powers of two", then? Consider the series . Since we can rewrite it as , these numbers are "powers of two". Let's see how this relates to our problem: If we fold a piece of paper 0 times, we end up with layer of paper. If we fold it once, we end up with 2 layers, then 4, 8, 16, 32, and so on. Therefore, in order to solve , we need to find the number in the series closest to 4 trillion.
Don't Panic. There's a very simple rule of thumb we can use here. Some powers of two are notable due to their implications in modern software. Not to get into too much technical detail, binary numbers are limited in range by the number of bits available. In computers, bits are usually grouped together in sets of eight known as bytes. One byte can therefore represent any whole number from 0 (in binary: ) to 255 (). This is similar to how 3 digits can only represent numbers from 0 to 999 using the decimal system.
In the original Pokémon games for the Game Boy, for example, the number 255 () was the highest possible number a Pokémon could reach in a statistic (attack, speed, etc.), since its value was stored in 1 byte on the game cartridge. YouTube encountered a similar problem when Gangnam Style reached over 2 billion views and the view counter (at the time) could only count to around 2,147 million (, the max value of a 32-bit signed integer).
Fun binary stories aside, our rule of thumb uses the number . As we concluded earlier, approximations are mostly harmless when working with exponentials. Therefore we can pretend that . With this powerful trick, we can easily solve the rest of our problem:
QED.
The author's definition of "cool" is entirely subjective and somewhat questionable.
Since we don't know how to fold a piece of paper 41.86 times, we will need to fold it 42 times in order to reach the moon. This is why remembering the exact distance to the moon is unnecessary. Using e.g. 300,000 km instead of 400,000 km will result in , resulting in the same answer of 42 folds.
You may also have run into strings like , , , , etc. These are hexadecimal numbers. They can be interpreted as shorthand for binary numbers where e.g. , , , and .