login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A003987 Table of n XOR m (or Nim-sum of n and m) read by antidiagonals, i.e., with entries in the order (n,m) = (0,0), (0,1), (1,0), (0,2), (1,1), (2,0), ... 118

%I

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

%N Table of n XOR m (or Nim-sum of n and m) read by antidiagonals, i.e., with entries in the order (n,m) = (0,0), (0,1), (1,0), (0,2), (1,1), (2,0), ...

%C 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 After a few moves the matrix looks like this:

%C 0 1 2 3 4 ...

%C 1 0 3 2 5 ...

%C 2 3 0 1 ?

%C The ? is then replaced with a 6.

%D J. H. Conway, On Numbers and Games. Academic Press, NY, 1976, pp. 51-53.

%D 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 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 T. D. Noe, <a href="/A003987/b003987.txt">Rows n=0..100 of triangle, flattened</a>

%H 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 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 <a href="/index/Ni#Nimsums">Index entries for sequences related to Nim-sums</a>

%F T(2i,2j) = 2T(i,j), T(2i+1,2j) = 2T(i,j) + 1.

%e Table begins

%e 0 1 2 3 4 5 6 7 ...

%e 1 0 3 2 5 4 7 6 ...

%e 2 3 0 1 6 7 4 5 ...

%e 3 2 1 0 7 6 5 4 ...

%e 4 5 6 7 0 1 2 3 ...

%e 5 4 7 6 1 0 3 2 ...

%e 6 7 4 5 2 3 0 1 ...

%e 7 6 5 4 3 2 1 0 ...

%e ...................

%p 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 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 # alternative:

%p read("transforms") :

%p A003987 := proc(n,m)

%p XORnos(n,m) ;

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

%p seq(seq(Bits:-Xor(k,m-k),k=0..m),m=0..20); # _Robert Israel_, Dec 31 2015

%t Flatten[Table[BitXor[b, a - b], {a, 0, 10}, {b, 0, a}]] (* BitXor and Nim Sum are equivalent *)

%o (PARI) tabl(nn) = {for(n=0, nn, for(k=0, n, print1(bitxor(k, n - k),", ");); print(););};

%o tabl(13) \\ _Indranil Ghosh_, Mar 31 2017

%o (Python)

%o for n in xrange(0, 14):

%o ....print [k^(n - k) for k in xrange(0, n + 1)] # _Indranil Ghosh_, Mar 31 2017

%Y Initial rows are A001477, A004442, A004443, A004444, etc. Cf. A051775, A051776.

%Y Cf. A003986 (OR) and A004198 (AND).

%Y Antidiagonal sums are in A006582.

%K tabl,nonn,nice,look

%O 0,4

%A _Marc LeBrun_

%E Example corrected and formatted by _Tilman Piesk_, May 29 2011

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent | More pages
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy .

Last modified February 19 10:31 EST 2018. Contains 299330 sequences. (Running on oeis4.)