login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A224923 Sum_{i=0..n} Sum_{j=0..n} (i XOR j), where XOR is the binary logical exclusive-or operator. 4
0, 2, 12, 24, 68, 114, 168, 224, 408, 594, 788, 984, 1212, 1442, 1680, 1920, 2672, 3426, 4188, 4952, 5748, 6546, 7352, 8160, 9096, 10034, 10980, 11928, 12908, 13890, 14880, 15872, 18912, 21954, 25004, 28056, 31140, 34226, 37320, 40416, 43640, 46866, 50100, 53336, 56604 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,2

LINKS

Alois P. Heinz, Table of n, a(n) for n = 0..1023

PROG

(Python)

for n in range(99):

....s = 0

....for i in range(n+1):

........for j in range(n+1):

............s += i ^ j

....print s, # Alex Ratushnyak, Apr 19 2013

(Python)

# O(log(n)) version, whereas program above is O(n^2)

def countPots2Until(n):

....nbPots = {1:n>>1}

....lftMask = ~3

....rgtMask = 1

....digit = 2

....while True:

........lft = (n & lftMask) >> 1

........rgt = n & rgtMask

........nbDigs = lft

........if n & digit:

............nbDigs |= rgt

........if nbDigs == 0:

............return nbPots

........nbPots[digit] = nbDigs

........rgtMask |= digit

........digit <<= 1

........lftMask = lftMask ^ digit

def sumXorSquare(n):

...."""Returns sum(i^j for i, j <= n)"""

....n += 1

....nbPots = countPots2Until(n)

....return 2 * sum(pot * freq * (n - freq) for pot, freq in nbPots.items())

print([sumXorSquare(n) for n in range(100)])  # Miguel Garcia Diaz, Nov 19 2014

CROSSREFS

Cf. A004125, A222423, A224915, A224924.

Sequence in context: A146567 A176679 A278407 * A247086 A121119 A226899

Adjacent sequences:  A224920 A224921 A224922 * A224924 A224925 A224926

KEYWORD

nonn,base

AUTHOR

Alex Ratushnyak, Apr 19 2013

STATUS

approved

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified June 15 17:43 EDT 2019. Contains 324142 sequences. (Running on oeis4.)