A329002 a(n) is the smallest d such that the sum of digits of 2^d + n is equal to d, or -1 if no such d exists.
5, 9, 103, 10, 3, 7, 4, 2, 1, 5, 9, 12, 10, 3, 7, 4, 2, 18, 5, 9, 12, 10, 3, 7, 4, 20, 18, 70, 9, 12, 10
Offset: 0
Examples
n=1: 2^9 + 1 = 513 has digit sum 9, so a(1) = 9. n=2: 2^103 + 2 has digit sum 103, and no smaller number has this property, so a(2) = 103.
Programs
-
Mathematica
Array[Block[{d = 1}, While[Total@ IntegerDigits[2^d + #] != d, d++]; d] &, 31, 0] (* Michael De Vlieger, Dec 29 2019 *)
-
PARI
a(n) = my(d=1); while (sumdigits(2^d+n) != d, d++); d; \\ Michel Marcus, Nov 12 2023
Comments