login
A387907
a(n) = position of first odd digit of 2^n, starting from left, or 0 if no odd digit exists.
2
1, 0, 0, 0, 1, 1, 0, 1, 2, 1, 1, 0, 3, 2, 1, 1, 2, 1, 4, 1, 1, 3, 2, 2, 1, 1, 2, 1, 5, 1, 1, 2, 3, 2, 1, 1, 3, 1, 2, 1, 1, 2, 2, 2, 1, 1, 1, 1, 3, 1, 1, 3, 2, 1, 1, 1, 1, 1, 5, 1, 1, 2, 3, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 7, 1, 3, 3, 1, 1, 1
OFFSET
0,9
COMMENTS
It is conjectured that a(n) is positive for n >= 12. This is sometimes known as the "2048 problem".
The first digit of 2^n follows Benford's law asymptotically (see Raimi reference), so the proportion of n with a(n) = 1 is log10(2*4*6*8*10) - log10(3*5*7*9) ~= 0.6088... .
LINKS
Ralph A. Raimi, The first digit problem, Amer. Math. Monthly, 83 (1976), 521-538.
Wikipedia, Benford's law
FORMULA
a(n) = 0 iff 2^n in A068994. - Michael S. Branicky, Sep 20 2025
EXAMPLE
a(6) = 0 because 2^6 = 64 has no odd digits.
a(10) = 1 because the first digit of 2^10 = 1024, from the left, is odd.
a(18) = 4 because the first odd digit of 2^18 = 262144, from the left, is the 4th digit.
MATHEMATICA
a[n_]:=Module[{so=Boole[OddQ/@IntegerDigits[2^n]]}, If[Total[so]==0, 0, Position[so, 1][[1]]]]; Array[a, 86, 0]//Flatten (* James C. McMahon, Sep 20 2025 *)
PROG
(PARI) a(n) = my(x=select(x->(x%2), digits(2^n), 1)); if (#x, x[1], 0); \\ Michel Marcus, Sep 14 2025
(Python)
def a(n): return next((i+1 for i, d in enumerate(str(1<<n)) if d in "13579"), 0)
print([a(n) for n in range(86)]) # Michael S. Branicky, Sep 15 2025
(Haskell)
import Data.Char
a387907 n = firstOddDigitPos $ 2^n
firstOddDigitPos n =
let digits = map digitToInt (show n)
indexedDigits = zip [1..] digits
oddPositions = filter (\(pos, digit) -> odd digit) indexedDigits
in case oddPositions of
[] -> 0
(x:_) -> fst x
-- Harry Richman, Sep 23 2025
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Harry Richman, Sep 12 2025
STATUS
approved