CEMC Banner

Problem of the Month
Problem 1: A bit of binary

October 2024

When we ordinarily write an integer, we write it in base-10, using digits from the set {0,1,2,3,4,5,6,7,8,9}. For example, when we write 743 what we mean is 743=7×102+4×101+3×100. However, there is nothing special about 10, and we can use other numbers as a base! Integers can also be written in base-2, and we call this writing an integer in binary. When writing an integer in binary, we use powers of 2 instead of powers of 10, and we use the "digits" from the set {0,1} ("digits" is in scare quotes because binary digits are called bits). We are going to explore some problems related to writing numbers in binary.

How do we write a number, say 121, in binary? Well, it’s not that different to writing it in base-10. First, find the largest power of 2 which is less than or equal to 121, which is 26=64. Subtracting this power gives us 12164=57. Then we repeat with 57, and continue this way until we are left with only a power of 2. With 121 this process looks like this: 121=26+5757=25+2525=24+99=23+11=20 Once we are done with this process, we conclude that 121=26+25+24+23+20. To be completely explicit, 121=1×26+1×25+1×24+1×23+0×22+0×21+1×20. More compactly, we write this as 121=[1111001]2.

This process works great for natural numbers, but it also works great for all real numbers! Typically, we write real numbers in base-10. For example, π=3.1415 means π=3×100+1×101+4×102+1×103+5×104+. To write π in binary, we follow the procedure above: find the highest power of 2 less than or equal to π, subtract it, and repeat. The first few steps look like this: π=21+(π2)π2=20+(π3)π3=23+(π258) Therefore, π=1×21+1×20+0×21+0×22+1×23+ or more succinctly, π=[11.001]2 (take a moment and prove that these calculations are correct, that is, for example, that 23 is indeed the largest power of 2 less than or equal to π3).

Before we get started on the questions, here are a couple of important facts you can take for granted without proof.

Fact 1: The binary expansions [0.a1a2ak01]2 and [0.a1a2ak1]2 represent the same number. This is due to the fact that 12+122+123+=1. As a result, we never write a binary number ending in an infinite string of 1’s. This is analogous to the fact that the decimal expansions 0.9 and 1 are decimal expansions of the same number (that number being the number 1).

Fact 2: With Fact 1 taken care of, every real number has a unique binary expansion.

Problems

    1. Compute the binary expansion of 279.

    2. Let k be a positive integer. Compute the binary expansion of 2k1.

    3. Let 3=[a0.a1a2a3a4]2. Compute a0,a1,a2,a3, and a4.

  1. In base-10, 17=0.142857. In this question we will find the binary expansion of 17, which will also be repeating.

    1. Find a pair of positive integers k and n so that 2k17=17+n.

    2. Let 17=[0.a1a2a3]2 (why is the only thing to the left of the decimal point a 0?). Using your values for k and n from part (a), write down binary expansions of 2k17 and 17+n in terms of the ai.

    3. Compute the binary expansion of 17. It should look like [0.a1a2at] for some t.

    4. Compute the binary expansion of 311.

  2. Let p be a prime. Prove that when p is written in binary, there are infinitely many 1’s and infinitely many 0’s.

  3. The floor of a real number x is denoted x, and is the largest integer n so that nx. Prove that the sequence 2,22,32,42,52 contains infinitely many powers of 2.