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.

A298818 a(n) is the binary XOR of all n-bit triangular numbers.

This page as a plain text file.
%I A298818 #19 Mar 01 2025 22:49:45
%S A298818 1,3,6,5,9,62,70,204,348,586,1770,3582,6974,9046,22486,12225,54977,
%T A298818 97140,201076,34728,347048,1031920,2250480,10857648,24157360,40826080,
%U A298818 112612576,21772545,130349313,1060428174,1126848910,1106260993,2017932289,3773334644,13412500596,6378289192,37614057512
%N A298818 a(n) is the binary XOR of all n-bit triangular numbers.
%C A298818 XOR is the binary exclusive-or operator.
%C A298818 Note { a(20), a(21) } = { 34728, 347048 }. First 3 and last digits are the same.
%C A298818 Also { a(27), a(31) } = { 112612576, 1126848910 }. First 4 decimal digits are the same.
%e A298818 There are two 4-bit triangular numbers, namely 10 and 15; a(4) = (10 XOR 15) = 5.
%o A298818 (Python)
%o A298818 i = n = x = L = 1
%o A298818 while L < 47:
%o A298818     i+=1
%o A298818     nextn = i*(i+1)//2
%o A298818     if (nextn ^ n) > n:
%o A298818         print(x, end=', ')
%o A298818         x = 0
%o A298818         prevL = L
%o A298818         L = len(bin(nextn))-2
%o A298818         for j in range(prevL, L-1):  print(0, end=', ')
%o A298818     n = nextn
%o A298818     x ^= n
%o A298818 (PARI) a(n) = {my(x = 0); for (k=2^(n-1), 2^n-1, if (ispolygonal(k, 3), x = bitxor(x, k)); ); x; } \\ _Michel Marcus_, Feb 13 2018
%Y A298818 Cf. A000217, A007088, A070939, A298816, A298817.
%K A298818 nonn,base
%O A298818 1,2
%A A298818 _Alex Ratushnyak_, Jan 26 2018