1import math22 ** 63math.log2(64)4math.log2(1000)5(1000).bit_length()62 ** 207math.log10(1000)2⁰2¹2²2³2⁴2⁵2⁶16422
Power cells: 2 to the power on top, its value belowBoard: 64 items in rows; lit squares are the current amountValue and exponent: the working number and its power of 2 (the log)Python card: ** for powers, math.log2 and math.log10 for logsOne number, 64 = 2⁶. The power cells at the back hold 2⁰ to 2⁶; the board holds items 1 to 64 in rows, and its lit squares are the current amount. Doubling six times builds 64 (the exponent counts the doublings); a binary search for item 22 halves the lit squares six times back to one (the log counts the halvings). So log₂(64) = 6. For a whole number n ≥ 1, the bits needed to write it are ⌊log₂ n⌋ + 1 (round the log down, add one): 64 needs 7 bits (1000000) and 1000 needs 10.

Exponents

  1. An exponent counts repeated multiplication. 2⁶ means six 2s multiplied: 2×2×2×2×2×2 = 64. Start from 1 and double six times. The exponent counts the doublings, and the board lights 1, 2, 4, 8, 16, 32, then 64 squares.

Logarithms

Real sizes

Try it in the Python prompt

;; step 1/9 · Exponents: repeated doubling
>>> 2 ** 6
64
>>> 2 * 2 * 2 * 2 * 2 * 2
64
>>> [2 ** i for i in range(7)]
[1, 2, 4, 8, 16, 32, 64]

log₂ and 2ˣ undo each other: log₂(2ˣ) = x and 2 to the power log₂(x) is x again. A log is only defined for numbers greater than 0. Use math.log2 and math.log10 for exact powers: math.log(1000, 10) divides two rounded logs and gives 2.9999999999999996, a tiny floating-point error.