OFFSET
0,4
LINKS
FORMULA
a(n) = a(n-1) + Sum_{i=0..e(a(n-1))} b(a(n-1), e(a(n-1))-i)*a(n-i-2) where b(k, i) is the i-th bit in the binary expansion of k, with b(k, 0) being the low order bit of k, and e(k) = floor(log_2(k)). The initial terms are a(0) = 0, a(1) = 1. [edited by Michel Marcus, Sep 28 2019 and Michael S. Branicky, Jan 19 2021]
MATHEMATICA
e[n_] := Floor[Log2[n]]; a[0] = 0; a[1] = 1; a[2] = 1; a[n_] := a[n] = a[n - 1] + Sum[BitGet[a[n - 1], em - i] * a[n - 2 - i], {i, 0, (em = e[a[n - 1]])}]; Array[a, 38, 0] (* Amiram Eldar, Sep 28 2019 *)
PROG
(PARI) lista(nn) = {my(va = vector(nn)); va[1] = 0; va[2] = 1; va[3] = 1; for (n=4, nn, my(b = binary(va[n-1])); va[n] = va[n-1] + sum(k=1, #b, b[k]*va[n-k-1]); ); va; } \\ Michel Marcus, Sep 28 2019
(Python)
def aupton(nn):
alst = [0, 1, 1]
for n in range(3, nn+1):
b = list(map(int, bin(alst[n-1])[2:]))
alst.append(alst[n-1] + sum(bi*alst[n-i-2] for i, bi in enumerate(b)))
return alst[:nn+1]
print(aupton(37)) # Michael S. Branicky, Jan 19 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Hilarie Orman, Sep 21 2019
STATUS
approved