login
A388137
a(n) = position of first even digit of 2^n, starting from left, or 0 if no even digit exists.
2
0, 1, 1, 1, 2, 2, 1, 2, 1, 3, 2, 1, 1, 1, 2, 2, 1, 4, 1, 2, 2, 1, 1, 1, 2, 5, 1, 3, 1, 3, 2, 1, 1, 1, 6, 2, 1, 4, 1, 2, 2, 1, 1, 1, 5, 4, 2, 2, 1, 2, 3, 1, 1, 2, 2, 2, 2, 2, 1, 3, 4, 1, 1, 2, 2, 2, 4, 2, 1, 3, 3, 1, 1, 2, 2, 5, 6, 8, 2, 1, 2, 1, 1, 2, 4, 2
OFFSET
0,5
COMMENTS
The first digit of the powers of two are known to follow Benford's Law asymptotically (see Raimi reference), so it follows that the proportion of n with a(n) = 1 is log10(3*5*7*9) - log10(2*4*6*8) = 0.3911....
LINKS
Ralph A. Raimi, The first digit problem, Amer. Math. Monthly, 83 (1976), 521-538.
Wikipedia, Benford's law
FORMULA
0 < a(n) <= A034887(n) for all n > 0, with equality iff 2^n in A272698. - Michael S. Branicky, Sep 20 2025
EXAMPLE
a(5) = 2, because the first even digit of 2^5 = 32 is the 2nd one from the left.
a(11) = 1, because the first even digit of 2^11 = 2048 is the 1st one from the left.
MAPLE
f:= proc(n) local L, i;
L:= convert(2^n, base, 10);
for i from 1 do if L[-i]::even then return i fi od
end proc:
f(0):= 0:
map(f, [$0..100]); # Robert Israel, Sep 21 2025
MATHEMATICA
a[n_] := (FirstPosition[IntegerDigits[2^n], _?EvenQ] /. _Missing -> {0})[[1]]; Array[a, 100, 0] (* Amiram Eldar, Sep 20 2025 *)
PROG
(PARI) a(n) = my(v=select(x->!(x%2), digits(2^n), 1)); if (#v, v[1], 0); \\ Michel Marcus, Sep 15 2025
(Python)
def a(n): return next((i+1 for i, d in enumerate(str(1<<n)) if d in "02468"), 0)
print([a(n) for n in range(86)]) # Michael S. Branicky, Sep 15 2025
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Harry Richman, Sep 15 2025
STATUS
approved