login
Bitwise XOR of first n triangular numbers.
3

%I #20 Feb 19 2023 17:35:57

%S 0,1,2,4,14,1,20,8,44,1,54,116,58,97,8,112,248,97,202,116,166,65,188,

%T 424,132,449,158,484,114,449,16,480,1008,449,914,484,894,449,804,40,

%U 796,65,966,116,938,1953,920,2032,872,1953,858,1652,790,1665,844,1352

%N Bitwise XOR of first n triangular numbers.

%H John Tyler Rascoe, <a href="/A193232/b193232.txt">Table of n, a(n) for n = 0..10000</a>

%p a:= proc(n) option remember; `if`(n=0, 0,

%p Bits[Xor](a(n-1), n*(n+1)/2))

%p end:

%p seq(a(n), n=0..55); # _Alois P. Heinz_, Feb 19 2023

%t Module[{nn=60,trs},trs=Accumulate[Range[nn]];Table[BitXor@@Take[trs,n],{n,0,nn}]] (* _Harvey P. Dale_, Dec 15 2017 *)

%o (PARI) al(n) = local(m); vector(n,k,m=bitxor(m,k*(k+1)\2))

%o (Python)

%o from operator import xor

%o from functools import reduce

%o def A193232(n): return reduce(xor, (x*(x+1) for x in range(n+1)))//2 # _Chai Wah Wu_, Dec 16 2021

%Y Cf. A000217, A145768, A003815.

%K nonn

%O 0,3

%A _Franklin T. Adams-Watters_, Jul 18 2011