Skip to content

The Binary Shortcut ​

The Shortcut ​

There's a classical shortcut for computing Collatz steps using binary arithmetic: a number n=2mc−1n = 2^m c - 1 with cc odd (so nn ends in exactly mm 1-bits) becomes 3mc−13^m c - 1 after mm steps of (3n+1)/2(3n+1)/2. I found it by playing with binary patterns, but it is well known. Here it is as a recipe:

  1. Take an odd number nn and write it in binary
  2. Count the trailing 1-bits (from the right). Call this mm.
  3. Split the binary string: S0S_0 = the left part, S1S_1 = the trailing 1s
  4. Compute: k=decimal(S0)+1k = \text{decimal}(S_0) + 1
  5. Result = k×3m−1k \times 3^m - 1

This gives you the value after mm applications of the shortcut map (3n+1)/2(3n+1)/2, skipping all the intermediate steps.

Worked Example: n = 27 ​

27=11011227 = 11011_2

Trailing 1-bits: 11 (two 1s, so m=2m = 2)

Split: S0=S_0 = "110" (decimal 6), S1=S_1 = "11"

k=6+1=7k = 6 + 1 = 7

Result =7×32−1=7×9−1=62= 7 \times 3^2 - 1 = 7 \times 9 - 1 = 62

Verify with step-by-step (3x+1)/2(3x+1)/2:

  • 27→(3×27+1)/2=82/2=4127 \to (3 \times 27 + 1)/2 = 82/2 = 41
  • 41→(3×41+1)/2=124/2=6241 \to (3 \times 41 + 1)/2 = 124/2 = 62 ✓

The shortcut jumped from 27 straight to 62, skipping 41 entirely.

More Examples ​

nnBinaryTrailing 1skkFormulaResultVerification
311211×9−11 \times 9 - 183→5→83 \to 5 \to 8 ✓
7111311×27−11 \times 27 - 1267→11→17→267 \to 11 \to 17 \to 26 ✓
151111411×81−11 \times 81 - 18015→23→35→53→8015 \to 23 \to 35 \to 53 \to 80 ✓
2711011277×9−17 \times 9 - 16227→41→6227 \to 41 \to 62 ✓
3111111511×243−11 \times 243 - 124231→47→⋯→24231 \to 47 \to \cdots \to 242 ✓

Notice the all-1s numbers (3,7,15,31,…=2k−13, 7, 15, 31, \ldots = 2^k - 1): they always give k=1k = 1, so the result is 3m−13^m - 1.

Why It Works: The Algebra ​

The formula has a clean algebraic form. If nn has mm trailing 1-bits, then:

n=2m⋅q+(2m−1)n = 2^m \cdot q + (2^m - 1)

where q=⌊n/2m⌋q = \lfloor n / 2^m \rfloor (the bits to the left of the trailing 1s, i.e., S0S_0).

Each application of (3x+1)/2(3x+1)/2 to an odd number xx gives (3x+1)/2(3x+1)/2. After mm applications:

result=(q+1)×3m−1=n+12m×3m−1=(n+1)×(32)m−1\text{result} = (q + 1) \times 3^m - 1 = \frac{n + 1}{2^m} \times 3^m - 1 = (n+1) \times \left(\frac{3}{2}\right)^m - 1

Proof by induction on mm.

Base (m=1m = 1): n=2q+1n = 2q + 1 (one trailing 1). (3(2q+1)+1)/2=(6q+4)/2=3q+2=3(q+1)−1(3(2q+1)+1)/2 = (6q+4)/2 = 3q+2 = 3(q+1) - 1. ✓

Step (m→m+1m \to m+1): n=2m+1q+(2m+1−1)n = 2^{m+1}q + (2^{m+1} - 1) has m+1m+1 trailing 1s.

After one (3x+1)/2(3x+1)/2: (3n+1)/2=3⋅2m(q+1)−1(3n+1)/2 = 3 \cdot 2^m(q+1) - 1

This equals 2m⋅[3(q+1)]+(2m−1)−2m2^m \cdot [3(q+1)] + (2^m - 1) - 2^m... more cleanly, it has mm trailing 1s with left part q′=3(q+1)−1q' = 3(q+1) - 1.

By the inductive hypothesis, mm more steps give: (q′+1)×3m−1=3(q+1)×3m−1=(q+1)×3m+1−1(q'+1) \times 3^m - 1 = 3(q+1) \times 3^m - 1 = (q+1) \times 3^{m+1} - 1. ✓

Connection to the Affine Orbit Structure ​

This shortcut is a special case of the Affine Orbit Structure theorem:

dest(n)=3s2k−s⋅n+C\text{dest}(n) = \frac{3^s}{2^{k-s} } \cdot n + C

The shortcut handles the case where s=ms = m (odd steps) and k−s=mk - s = m (even steps), i.e., k=2mk = 2m. Each odd step is followed by exactly one halving, so the slope is (3/2)m(3/2)^m: here the value grows, and the formula is the affine form for the parity word of those 2m2m steps, not a dropping destination.

The general theorem allows any sequence of alpha values — some steps might halve once (α=1\alpha = 1), others might halve many times (α=4,5,…\alpha = 4, 5, \ldots). The binary shortcut handles the specific case where all the halvings are singles.

Why Trailing 1s Matter ​

The trailing 1-bits in binary encode the 2-adic structure of nn:

  • Each trailing 1 means "the next (3x+1)/2(3x+1)/2 gives an odd result" (so we continue)
  • The first 0 means "the result will be even" (so we stop and halve)

This is the bit consumption property from the affine orbit proof: the last mm bits of nn determine the first mm steps of the orbit. A run of mm trailing 1s gives mm consecutive odd steps: in the alpha sequence, m−1m - 1 values α=1\alpha = 1 followed by one that is at least 2.

Trailing bitsOrbit behaviorAlpha values
...01One odd step, then even[α1][\alpha_1] where α1≥2\alpha_1 \geq 2
...011Two odd steps, then even[1,α2][1, \alpha_2] where α2≥2\alpha_2 \geq 2
...0111Three odd steps, then even[1,1,α3][1, 1, \alpha_3] where α3≥2\alpha_3 \geq 2
...01111Four odd steps, then even[1,1,1,α4][1, 1, 1, \alpha_4] where α4≥2\alpha_4 \geq 2

The binary shortcut processes the entire run of α=1\alpha = 1 values in one shot. The general affine structure handles arbitrary alpha sequences.

Try It ​

Enter an odd number to see the binary shortcut in action:

Binary Shortcut for 27

11011
S₀ = "110" (decimal 6)S₁ = "11" (2 trailing 1s)
k = 6 + 1 = 7
Result = 7 × 32 − 1 = 7 × 9 − 1 = 62

Verification: 2 steps of (3x+1)/2

27 → 41 → 62
✓ Match!