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

%I #37 Aug 22 2023 08:01:42

%S 0,1,5,6,22,23,27,28,92,93,97,98,114,115,119,120,376,377,381,382,398,

%T 399,403,404,468,469,473,474,490,491,495,496,1520,1521,1525,1526,1542,

%U 1543,1547,1548,1612,1613,1617,1618,1634,1635,1639,1640,1896,1897,1901,1902,1918

%N a(n) = Sum_{k=0..n} n XOR k where XOR is the bitwise logical exclusive-or operator.

%H Michael De Vlieger, <a href="/A224915/b224915.txt">Table of n, a(n) for n = 0..10000</a>

%F 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

%F 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

%F From _Kevin Ryde_, Dec 17 2021: (Start)

%F a(2*n+b) = 4*a(n) + n + b where b = 0 or 1.

%F a(n) = (A001196(n) - n)/2.

%F a(n) = A350093(n) - A222423(n), being XOR = OR - AND.

%F (End)

%e a(2) = (0 xor 2) + (1 xor 2) = 2 + 3 = 5.

%p read("transforms"):

%p A051933 := proc(n,k)

%p XORnos(n,k) ;

%p end proc:

%p A224915 := proc(n)

%p add(A051933(n,k),k=0..n) ;

%p end proc: # _R. J. Mathar_, Apr 26 2013

%p # second Maple program:

%p with(MmaTranslator[Mma]):

%p seq(add(BitXor(n,i),i=0..n),n=0..60); # _Ridouane Oudra_, Dec 09 2020

%t Array[Sum[BitXor[#, k], {k, 0, #}] &, 53, 0] (* _Michael De Vlieger_, Dec 09 2020 *)

%o (Python)

%o for n in range(59):

%o s = 0

%o for k in range(n): s += n ^ k

%o print(s, end=',')

%o (Python)

%o def A224915(n): return 3*int(bin(n)[2:],4)-n>>1 # _Chai Wah Wu_, Aug 21 2023

%o (PARI) a(n) = sum(k=0, n, bitxor(n, k)); \\ _Michel Marcus_, Jun 08 2019

%o (PARI) a(n) = (3*fromdigits(binary(n),4) - n) >>1; \\ _Kevin Ryde_, Dec 17 2021

%Y Cf. A001196 (bit doubling).

%Y Row sums of A051933.

%Y Other sums: A222423 (AND), A350093 (OR), A265736 (IMPL), A350094 (CNIMPL), A004125 (mod).

%K nonn,easy

%O 0,3

%A _Alex Ratushnyak_, Apr 19 2013

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 21:09 EDT 2024. Contains 371798 sequences. (Running on oeis4.)