login
a(n) is the sum of the numbers k < n such that a(k) AND n = a(k) (where AND denotes the bitwise AND operator).
3

%I #26 Mar 01 2022 14:51:13

%S 0,0,1,3,1,7,1,21,1,21,1,34,1,43,1,65,1,73,1,94,1,127,1,157,1,157,1,

%T 186,1,227,1,265,1,273,12,287,1,309,12,328,1,349,12,376,115,463,126,

%U 495,1,397,12,411,1,465,12,484,1,505,12,532,277,797,288,829,1

%N a(n) is the sum of the numbers k < n such that a(k) AND n = a(k) (where AND denotes the bitwise AND operator).

%C The definition is recursive: a(n) depends on prior terms (a(0), ..., a(n-1)); a(0) = a(1) = 0 correspond to empty sums.

%H Rémy Sigrist, <a href="/A350802/b350802.txt">Table of n, a(n) for n = 0..10000</a>

%e The first terms, alongside the corresponding k's, are:

%e n a(n) k's

%e -- ---- -------------------------

%e 0 0 {}

%e 1 0 {0}

%e 2 1 {0, 1}

%e 3 3 {0, 1, 2}

%e 4 1 {0, 1}

%e 5 7 {0, 1, 2, 4}

%e 6 1 {0, 1}

%e 7 21 {0, 1, 2, 3, 4, 5, 6}

%e 8 1 {0, 1}

%e 9 21 {0, 1, 2, 4, 6, 8}

%e 10 1 {0, 1}

%e 11 34 {0, 1, 2, 3, 4, 6, 8, 10}

%e 12 1 {0, 1}

%p a:= proc(n) option remember; add(

%p `if`(Bits[And](n, a(j))=a(j), j, 0), j=0..n-1)

%p end:

%p seq(a(n), n=0..80); # _Alois P. Heinz_, Feb 28 2022

%o (PARI) for (n=1, #a=vector(65), print1 (a[n]=sum(k=1, n-1, if (bitand(a[k], n-1)==a[k], k-1, 0))", "))

%Y Cf. A350677, A351887.

%K base,nonn

%O 0,4

%A _Rémy Sigrist_, Feb 25 2022