This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A330072 #42 May 19 2025 23:37:58 %S A330072 0,1,3,5,7,10,13,16,15,19,24,28,29,33,38,42,31,36,43,48,52,57,64,69, %T A330072 61,66,73,78,82,87,94,99,63,69,78,84,91,97,106,112,108,114,123,129, %U A330072 136,142,151,157,125,131,140,146,153,159,168,174,170,176,185,191,198 %N A330072 a(n) is the sum of all integers whose binary representation is contained in the binary representation of n (with multiplicity). %F A330072 a(2^k) = 2^(k+1)-1. %F A330072 a(2^k-1) = (8*2^k-8-5*k-k^2)/2. - _Giovanni Resta_, Dec 02 2019 %F A330072 From _David Radcliffe_, May 14 2025: (Start) %F A330072 a(n) = Sum_{i=0..b} Sum_{j=0..b-i} ([n/2^i] mod 2^j) where b is the bit length of n. %F A330072 a(n) - 3a([n/2]) + 2a([n/4]) = A070939(n) if n is odd, 0 otherwise. (End) %e A330072 For n = 5: 5 in binary is 101, so a(n) = 101 + 10 + 01 + 1 + 0 + 1 in binary, which is 5 + 2 + 1 + 1 + 0 + 1 = 10. %t A330072 a[n_] := Block[{d = IntegerDigits[n, 2]}, Sum[FromDigits[Take[d, {i, j}], 2], {j, Length[d]}, {i, j}]]; Array[a, 61, 0] (* _Giovanni Resta_, Dec 02 2019 *) %o A330072 (Python) %o A330072 def bitlist(n): %o A330072 output = [] %o A330072 while n != 0: %o A330072 output.append(n % 2) %o A330072 n //= 2 %o A330072 return output %o A330072 #converts a number into a list of the digits in binary reversed %o A330072 def bitsum(bitlist): %o A330072 output = 0 %o A330072 for bit in bitlist: %o A330072 if bit == 1: %o A330072 output += 1 %o A330072 return output %o A330072 #gives the cross sum of a bitlist %o A330072 def a(bitlist): %o A330072 output = 0 %o A330072 l = len(bitlist) %o A330072 for x in range(l): %o A330072 output += bitlist[x] * (l - x) * (2**(x + 1) - 1) %o A330072 return output %o A330072 #to get the first 60 numbers of the sequence, write: %o A330072 for x in range(0, 60): %o A330072 print(a(bitlist(x))) %o A330072 (Python) %o A330072 def a(n): %o A330072 b = n.bit_length() %o A330072 return sum((n//2**i) % (2**j) for i in range(b+1) for j in range(b-i+1)) %o A330072 # _David Radcliffe_, May 14 2025 %Y A330072 Cf. A007088, A005187, A049802, A078823, A225580 (base-10 version). %K A330072 nonn,base %O A330072 0,3 %A A330072 _Tonio Kettner_, Nov 30 2019