OFFSET
0,4
COMMENTS
For n >= 2, a(n) <= n - 1, and is exactly n - 1 for all n = 2^t + 2.
Consider the diverging sum Sum_{k>=0} 4^k/k!. For k >= a(n), v(4^k/k!, 2) = A092391(k) >= n. As a result, the sum contains only finitely many nonzero terms (and thus converges) modulo 2^n for all n, that is, it converges in the 2-adic field. Here v(k, 2) is the 2-adic valuation of k.
EXAMPLE
MATHEMATICA
a[n_] := Module[{i = n-1-Boole[n >= 2]}, While[i+Total[IntegerDigits[i, 2]] >= n, i--]; i+1]; a[0]=0; Table[a[n], {n, 0, 67}] (* Jean-François Alcover, Nov 23 2018, from PARI *)
PROG
(PARI) a(n) = if(n, my(i=n-1-(n>=2)); while(i+hammingweight(i)>=n, i--); i+1, 0)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Jianing Song, Oct 22 2018
STATUS
approved