Lesson goal: Number Bases Equivalence

Previous: Numbers ending in 1 | Home | Next: Linear Diophantine equations

In our standard decimal system (base 10), the number $47$ means: $$4 \times 10 + 7 = 47$$ In an arbitrary integer base $b$, a two-digit numeral $d_1 d_0$ represents the value: $$d_1 \times b + d_0$$ Because the largest digit in base $b$ is $b - 1$, any base containing the digit 7 must satisfy $b > 7$ (i.e. $b \ge 8$). In the 1971 MAA High School Mathematics Contest (Problem #11), students were asked: The numeral 47 in base $a$ represents the same number as 74 in base $b$. What is the smallest possible base $a$ and base $b$? Equating their values: $$4a + 7 = 7b + 4$$ $$4a + 3 = 7b$$ Instead of guessing fractions, we can write nested for-loops in Lua to search over integer bases $a$ and $b$ starting from $8$, checking for the first pair where the values match!
val_a = 4 * a + 7
val_b = 7 * b + 4

if val_a == val_b then

  print("Match found! a =", a, "b =", b)
end
Move the mouse over a dotted box for more information.

Notice that because $7b$ must be odd ($4a + 3$ is always odd), base $b$ must be an odd integer ($9, 11, 13, \dots$).

Now you try. Fill in val_a = 4 * a + 7, val_b = 7 * b + 4, and val_a == val_b. Run the script to find the smallest integer bases that satisfy the contest problem!

Type your code here:


See your results here: