Category: Number Theory Level: 101
13 → 11012: divide by 2, keep remainders, read bottom to top
Divide by 2 again and again and write down each remainder. The remainders, read from the bottom up, are the binary digits.
13 ÷ 2 = 6 remainder 1. An odd number always leaves remainder 1, and that 1 is the last binary digit.
13 = 2 × 6 + 1
Divide the quotient again: 6 ÷ 2 = 3 remainder 0. Each new remainder is the next place to the left.
6 = 2 × 3 + 0
3 ÷ 2 = 1 R 1, then 1 ÷ 2 = 0 R 1. A quotient of 0 means stop.
3 = 2 × 1 + 1, 1 = 2 × 0 + 1
The last remainder is the biggest place. Read up the column to get 1101. Same answer as filling places with 8, 4, 2, 1.
13 = 11012
cd svg-generator python3 -m svgmath render binary-by-halving --out /tmp/binary-by-halving
Source: svgmath/diagrams/binary.py