A078677 Write n in binary; repeatedly sum the "digits" until reaching 1; a(n) = sum of these sums (including '1' and n itself).
1, 3, 6, 5, 8, 9, 13, 9, 12, 13, 17, 15, 19, 20, 20, 17, 20, 21, 25, 23, 27, 28, 28, 27, 31, 32, 32, 34, 34, 35, 39, 33, 36, 37, 41, 39, 43, 44, 44, 43, 47, 48, 48, 50, 50, 51, 55, 51, 55, 56, 56, 58, 58, 59, 63, 62, 62, 63, 67, 65, 69, 70, 72, 65, 68, 69, 73, 71, 75, 76, 76, 75
Offset: 1
Examples
a(13) = 19 because 13 = (1101) -> (1+1+0+1 = 11) -> (1+1 = 10) -> (1+0 = 1) = 1 and 1101+11+10+1 (binary) = 19 (decimal).
Links
- Paolo Xausa, Table of n, a(n) for n = 1..10000
Programs
-
Mathematica
A078677[n_] := Total[NestWhileList[DigitSum[#, 2] &, n, # > 1 &]]; Array[A078677, 100] (* Paolo Xausa, Mar 11 2025 *)
-
Python
def a(n): s = n if n > 1 else 0 while (n:=n.bit_count()) > 1: s += n return s + 1 print([a(n) for n in range(1, 73)]) # Michael S. Branicky, Mar 12 2025
Formula
a(1) = 1; for n > 1, a(n) = n + a(A000120(n)).