OFFSET
0,2
FORMULA
Sum_{n>=1} (-1)^(n+1)/a(n) = Sum_{n>=1} (-1)^(n+1)/A059009(n) = 0.395592509... . - Amiram Eldar, Feb 18 2024
EXAMPLE
The binary representation of 16 is 10000, which has four 0-bits (and one 1-bit), hence 16 appears four times in this sequence (but only once in A100922).
MATHEMATICA
Flatten[Table[Table[n, {DigitCount[n, 2, 0]}], {n, 0, 37}]] (* Amiram Eldar, Feb 18 2024 *)
PROG
(Python)
def A059015(n): return 2+(n+1)*((t:=(n+1).bit_length())-n.bit_count())-(1<<t)-(sum((m:=1<<j)*((k:=n>>j)-(r if n<<1>=m*(r:=k<<1|1) else 0)) for j in range(1, n.bit_length()+1))>>1)
def A100921(n):
if n == 0: return 0
m, k = 1, 1
while A059015(m)<=n: m<<=1
while m-k>1:
r = m+k>>1
if A059015(r)>n:
m = r
else:
k = r
return m # Chai Wah Wu, Nov 11 2024
CROSSREFS
KEYWORD
base,easy,nonn
AUTHOR
Rick L. Shepherd, Nov 21 2004
STATUS
approved