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.

A003987 Table of n XOR m (or Nim-sum of n and m) read by antidiagonals with m>=0, n>=0.

This page as a plain text file.
%I A003987 #89 Mar 17 2025 11:35:01
%S A003987 0,1,1,2,0,2,3,3,3,3,4,2,0,2,4,5,5,1,1,5,5,6,4,6,0,6,4,6,7,7,7,7,7,7,
%T A003987 7,7,8,6,4,6,0,6,4,6,8,9,9,5,5,1,1,5,5,9,9,10,8,10,4,2,0,2,4,10,8,10,
%U A003987 11,11,11,11,3,3,3,3,11,11,11,11,12,10,8,10,12,2,0,2,12,10,8,10,12,13,13,9,9,13,13,1,1,13,13,9,9,13,13
%N A003987 Table of n XOR m (or Nim-sum of n and m) read by antidiagonals with m>=0, n>=0.
%C A003987 Another way to construct the array: construct an infinite square matrix starting in the top left corner using the rule that each entry is the smallest nonnegative number that is not in the row to your left or in the column above you.
%C A003987 After a few moves the [symmetric] matrix looks like this:
%C A003987   0 1 2 3 4 5 ...
%C A003987   1 0 3 2 5 ...
%C A003987   2 3 0 1 ?
%C A003987   3 2 1
%C A003987   4 5 ?
%C A003987   5
%C A003987 The ? is then replaced with a 6.
%D A003987 E. R. Berlekamp, J. H. Conway and R. K. Guy, Winning Ways, Academic Press, NY, 2 vols., 1982, see p. 60.
%D A003987 J. H. Conway, On Numbers and Games. Academic Press, NY, 1976, pp. 51-53.
%D A003987 Eric Friedman, Scott M. Garrabrant, Ilona K. Phipps-Morgan, A. S. Landsberg and Urban Larsson, Geometric analysis of a generalized Wythoff game, in Games of no Chance 5, MSRI publ. Cambridge University Press, date?
%D A003987 D. Gale, Tracking the Automatic Ant and Other Mathematical Explorations, A Collection of Mathematical Entertainments Columns from The Mathematical Intelligencer, Springer, 1998; see p. 190. [From _N. J. A. Sloane_, Jul 14 2009]
%D A003987 R. K. Guy, Impartial games, pp. 35-55 of Combinatorial Games, ed. R. K. Guy, Proc. Sympos. Appl. Math., 43, Amer. Math. Soc., 1991.
%H A003987 T. D. Noe, <a href="/A003987/b003987.txt">Rows n = 0..100 of triangle, flattened</a>
%H A003987 J.-P. Allouche and J. Shallit, <a href="https://doi.org/10.1016/S0304-3975(03)00090-2">The Ring of k-regular Sequences, II</a>, Theoret. Computer Sci., 307 (2003), 3-29.
%H A003987 Rémy Sigrist, <a href="/A003987/a003987.png">Colored representation of T(x,y) for x = 0..1023 and y = 0..1023</a> (where the hue is function of T(x,y) and black pixels correspond to zeros)
%H A003987 N. J. A. Sloane, <a href="http://neilsloane.com/doc/sg.txt">My favorite integer sequences</a>, in Sequences and their Applications (Proceedings of SETA '98).
%H A003987 N. J. A. Sloane, <a href="https://arxiv.org/abs/2105.05111">The OEIS: A Fingerprint File for Mathematics</a>, arXiv:2105.05111 [math.HO], 2021. Mentions this sequence.
%H A003987 <a href="/index/Ni#Nimsums">Index entries for sequences related to Nim-sums</a>
%F A003987 T(2i,2j) = 2T(i,j), T(2i+1,2j) = 2T(i,j) + 1.
%e A003987 Table begins
%e A003987    0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, ...
%e A003987    1,  0,  3,  2,  5,  4,  7,  6,  9,  8, 11, 10, ...
%e A003987    2,  3,  0,  1,  6,  7,  4,  5, 10, 11,  8, ...
%e A003987    3,  2,  1,  0,  7,  6,  5,  4, 11, 10, ...
%e A003987    4,  5,  6,  7,  0,  1,  2,  3, 12, ...
%e A003987    5,  4,  7,  6,  1,  0,  3,  2, ...
%e A003987    6,  7,  4,  5,  2,  3,  0, ...
%e A003987    7,  6,  5,  4,  3,  2, ...
%e A003987    8,  9, 10, 11, 12, ...
%e A003987    9,  8, 11, 10, ...
%e A003987   10, 11,  8, ...
%e A003987   11, 10, ...
%e A003987   12, ...
%e A003987   ...
%e A003987 The first few antidiagonals are
%e A003987    0;
%e A003987    1,  1;
%e A003987    2,  0,  2;
%e A003987    3,  3,  3,  3;
%e A003987    4,  2,  0,  2,  4;
%e A003987    5,  5,  1,  1,  5,  5;
%e A003987    6,  4,  6,  0,  6,  4,  6;
%e A003987    7,  7,  7,  7,  7,  7,  7,  7;
%e A003987    8,  6,  4,  6,  0,  6,  4,  6,  8;
%e A003987    9,  9,  5,  5,  1,  1,  5,  5,  9,  9;
%e A003987   10,  8, 10,  4,  2,  0,  2,  4, 10,  8, 10;
%e A003987   11, 11, 11, 11,  3,  3,  3,  3, 11, 11, 11, 11;
%e A003987   12, 10,  8, 10, 12,  2,  0,  2, 12, 10,  8, 10, 12;
%e A003987   ...
%e A003987 [Symmetric] matrix in base 2:
%e A003987      0    1   10   11  100  101,  110  111 1000 1001 1010 1011 ...
%e A003987      1    0   11   10  101  100,  111  110 1001 1000 1011  ...
%e A003987     10   11    0    1  110  111,  100  101 1010 1011  ...
%e A003987     11   10    1    0  111  110,  101  100 1011  ...
%e A003987    100  101  110  111    0    1    10   11  ...
%e A003987    101  100  111  110    1    0    11  ...
%e A003987    110  111  100  101   10   11   ...
%e A003987    111  110  101  100   11  ...
%e A003987   1000 1001 1010 1011  ...
%e A003987   1001 1000 1011  ...
%e A003987   1010 1011  ...
%e A003987   1011  ...
%e A003987    ...
%p A003987 nimsum := proc(a,b) local t1,t2,t3,t4,l; t1 := convert(a+2^20,base,2); t2 := convert(b+2^20,base,2); t3 := evalm(t1+t2); map(x->x mod 2, t3); t4 := convert(evalm(%),list); l := convert(t4,base,2,10); sum(l[k]*10^(k-1), k=1..nops(l)); end; # memo: adjust 2^20 to be much bigger than a and b
%p A003987 AT := array(0..N,0..N); for a from 0 to N do for b from a to N do AT[a,b] := nimsum(a,b); AT[b,a] := AT[a,b]; od: od:
%p A003987 # alternative:
%p A003987 read("transforms") :
%p A003987 A003987 := proc(n,m)
%p A003987     XORnos(n,m) ;
%p A003987 end proc: # _R. J. Mathar_, Apr 17 2013
%p A003987 seq(seq(Bits:-Xor(k,m-k),k=0..m),m=0..20); # _Robert Israel_, Dec 31 2015
%t A003987 Flatten[Table[BitXor[b, a - b], {a, 0, 10}, {b, 0, a}]] (* BitXor and Nim Sum are equivalent *)
%o A003987 (PARI) tabl(nn) = {for(n=0, nn, for(k=0, n, print1(bitxor(k, n - k),", ");); print(););};
%o A003987 tabl(13) \\ _Indranil Ghosh_, Mar 31 2017
%o A003987 (Python)
%o A003987 for n in range(14):
%o A003987     print([k^(n - k) for k in range(n + 1)]) # _Indranil Ghosh_, Mar 31 2017
%Y A003987 Initial rows are A001477, A004442, A004443, A004444, etc. Cf. A051775, A051776.
%Y A003987 Cf. A003986 (OR), A004198 (AND), A221146 (carries).
%Y A003987 Antidiagonal sums are in A006582.
%K A003987 tabl,nonn,nice,look
%O A003987 0,4
%A A003987 _Marc LeBrun_