login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A330072 a(n) is the sum of all integers whose binary representation is contained in the binary representation of n (with multiplicity). 0
0, 1, 3, 5, 7, 10, 13, 16, 15, 19, 24, 28, 29, 33, 38, 42, 31, 36, 43, 48, 52, 57, 64, 69, 61, 66, 73, 78, 82, 87, 94, 99, 63, 69, 78, 84, 91, 97, 106, 112, 108, 114, 123, 129, 136, 142, 151, 157, 125, 131, 140, 146, 153, 159, 168, 174, 170, 176, 185, 191, 198 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,3
LINKS
FORMULA
a(2^k) = 2^(k+1)-1.
a(2^k-1) = (8*2^k-8-5*k-k^2)/2. - Giovanni Resta, Dec 02 2019
EXAMPLE
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.
MATHEMATICA
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 *)
PROG
(Python)
def bitlist(n):
output = []
while n != 0:
output.append(n % 2)
n /= 2
return output
#converts a number into a list of the digits in binary reversed
def bitsum(bitlist):
output = 0
for bit in bitlist:
if bit == 1:
output += 1
return output
#gives the cross sum of a bitlist
def a(bitlist):
output = 0
l = len(bitlist)
for x in range(l):
output += bitlist[x] * (l - x) * (2**(x + 1) - 1)
return output
#to get the first n numbers of the sequence, write:
for x in range(1, n + 1):
print x, a(bitlist(x))
CROSSREFS
Sequence in context: A152004 A298862 A198409 * A213510 A130257 A276498
KEYWORD
nonn,base
AUTHOR
Tonio Kettner, Nov 30 2019
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 19:02 EDT 2024. Contains 371798 sequences. (Running on oeis4.)