The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
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!)
A224915 a(n) = Sum_{k=0..n} n XOR k where XOR is the bitwise logical exclusive-or operator. 6
0, 1, 5, 6, 22, 23, 27, 28, 92, 93, 97, 98, 114, 115, 119, 120, 376, 377, 381, 382, 398, 399, 403, 404, 468, 469, 473, 474, 490, 491, 495, 496, 1520, 1521, 1525, 1526, 1542, 1543, 1547, 1548, 1612, 1613, 1617, 1618, 1634, 1635, 1639, 1640, 1896, 1897, 1901, 1902, 1918 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,3
LINKS
FORMULA
a(n) = Sum_{j=1..n} 4^(v_2(j)), where v_2(j) is the exponent of highest power of 2 dividing j. - Ridouane Oudra, Jun 08 2019
a(n) = n + 3*Sum_{j=1..floor(log_2(n))} 4^(j-1)*floor(n/2^j), for n>=1. - Ridouane Oudra, Dec 09 2020
From Kevin Ryde, Dec 17 2021: (Start)
a(2*n+b) = 4*a(n) + n + b where b = 0 or 1.
a(n) = (A001196(n) - n)/2.
a(n) = A350093(n) - A222423(n), being XOR = OR - AND.
(End)
EXAMPLE
a(2) = (0 xor 2) + (1 xor 2) = 2 + 3 = 5.
MAPLE
read("transforms"):
A051933 := proc(n, k)
XORnos(n, k) ;
end proc:
A224915 := proc(n)
add(A051933(n, k), k=0..n) ;
end proc: # R. J. Mathar, Apr 26 2013
# second Maple program:
with(MmaTranslator[Mma]):
seq(add(BitXor(n, i), i=0..n), n=0..60); # Ridouane Oudra, Dec 09 2020
MATHEMATICA
Array[Sum[BitXor[#, k], {k, 0, #}] &, 53, 0] (* Michael De Vlieger, Dec 09 2020 *)
PROG
(Python)
for n in range(59):
s = 0
for k in range(n): s += n ^ k
print(s, end=', ')
(Python)
def A224915(n): return 3*int(bin(n)[2:], 4)-n>>1 # Chai Wah Wu, Aug 21 2023
(PARI) a(n) = sum(k=0, n, bitxor(n, k)); \\ Michel Marcus, Jun 08 2019
(PARI) a(n) = (3*fromdigits(binary(n), 4) - n) >>1; \\ Kevin Ryde, Dec 17 2021
CROSSREFS
Cf. A001196 (bit doubling).
Row sums of A051933.
Other sums: A222423 (AND), A350093 (OR), A265736 (IMPL), A350094 (CNIMPL), A004125 (mod).
Sequence in context: A132796 A006492 A110344 * A135301 A294175 A369853
KEYWORD
nonn,easy
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 | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 13 03:04 EDT 2024. Contains 372497 sequences. (Running on oeis4.)