cp's OEIS Frontend

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.

A382865 Bitwise XOR of all integers between n and 2n (endpoints included).

This page as a plain text file.
%I A382865 #69 Jun 12 2025 19:29:43
%S A382865 0,3,5,4,8,15,13,8,16,27,21,28,24,23,29,16,32,51,37,52,40,63,45,56,48,
%T A382865 43,53,44,56,39,61,32,64,99,69,100,72,111,77,104,80,123,85,124,88,119,
%U A382865 93,112,96,83,101,84,104,95,109,88,112,75,117,76,120,71,125,64,128,195
%N A382865 Bitwise XOR of all integers between n and 2n (endpoints included).
%H A382865 Alois P. Heinz, <a href="/A382865/b382865.txt">Table of n, a(n) for n = 0..16383</a>
%H A382865 Karl-Heinz Hofmann, <a href="/A382865/a382865.gif">Zoom trip with n mod 4 colored.</a>
%H A382865 Wikipedia, <a href="https://en.wikipedia.org/wiki/Bitwise_operation#XOR">Bitwise operation: XOR</a>
%F A382865 a(2n) = A047615(n+1), and for every integer k>1: a(n*2^k -1) = 2^k * A065621(n).
%F A382865 a(4n) = 8*n, a(4n+1) = 2*A114389(n+1) + 1, a(4n+2) = 8*n + 5, a(4n+3) = 4*A065621(n+1).
%F A382865 From _Karl-Heinz Hofmann_, May 27 2025: (Start)
%F A382865 For all n == 0 (mod 4) --> a(n) = A005843(n) = 2*n
%F A382865 For all n == 1 (mod 4) --> a(n) = A048724(n)
%F A382865 For all n == 2 (mod 4) --> a(n) = A005408(n) = 2*n + 1
%F A382865 For all n == 3 (mod 4) --> a(n) = A048724(n) - 1 (End)
%F A382865 a(n) = (1/2) * XOR(A174091(n-1) - A181983(n-1), 4*n). - _Federico Provvedi_, May 31 2025
%e A382865 a(3) = 3 XOR 4 XOR 5 XOR 6 = 4, in binary representation is: ((011 XOR 100) XOR 101) XOR 110 = (111 XOR 101) XOR 110 = 010 XOR 110 = 100 (4 in decimal).
%p A382865 a:= proc(n) option remember; uses Bits; `if`(n=0, 0,
%p A382865       Xor(Xor(Xor(a(n-1), n-1), 2*n-1), 2*n))
%p A382865     end:
%p A382865 seq(a(n), n=0..65);  # _Alois P. Heinz_, May 26 2025
%t A382865 a[n_] = BitXor[BitOr[n-1, 2] - (-1)^n*(n-1), 4*n]/2; Table[a[n],{n,0, 65}]
%o A382865 (PARI) a(n) = my(b=n); for (i=n+1, 2*n, b = bitxor(b, i)); b; \\ _Michel Marcus_, May 25 2025
%o A382865 (Python)
%o A382865 def A382865(n): return [0, n, 1, n-1][n%4] ^ (2*n) # _Karl-Heinz Hofmann_, May 26 2025
%Y A382865 Cf. A038712, A047615, A065621, A114389, A010873, A048724, A174091, A181983.
%K A382865 nonn,look
%O A382865 0,2
%A A382865 _Federico Provvedi_, May 21 2025