%I #44 Jun 06 2022 11:16:46
%S 0,1,0,1,2,0,1,0,1,2,0,1,0,1,2,0,1,0,1,2,0,1,0,1,2,3,2,3,4,5,3,2,3,4,
%T 0,1,2,3,2,0,1,2,3,2,0,1,2,3,2,3,4,5,0,1,3,4,5,0,1,3,4,5,0,1,3,0,1,0,
%U 1,2,4,3,0,1,5,6,2,3,4,5,6,2,3,4,5,0,1,6,3,2,4,2,6,4,5,0,1,6,4
%N Nim-Grundy function for Take-a-Square (or Subtract-a-Square) game.
%C Concerning the January 1997 dissertation of Achim Flammenkamp, his home page (currently http://wwwhomes.uni-bielefeld.de/cgi-bin/cgiwrap/achim/index.cgi) has the link shown below, and a comment that a book was published in July 1997 by Hans-Jacobs-Verlag, Lage, Germany with the title Lange Perioden in Subtraktions-Spielen (ISBN 3-932136-10-1). This is an enlarged study (more than 200 pages) of his dissertation. - _N. J. A. Sloane_, Jul 25 2019
%D R. K. Guy, Unsolved Problems in Number Theory, E26.
%D W. W. Rouse Ball and H. S. M. Coxeter, Mathematical Recreations and Essays, 12th Edition.
%H Eric M. Schmidt, <a href="/A014586/b014586.txt">Table of n, a(n) for n = 0..10000</a> (corrected by _Eric M. Schmidt_, Apr 23 2019)
%H David Eppstein, <a href="https://arxiv.org/abs/1804.06515">Faster Evaluation of Subtraction Games</a>, Proceedings of the 9th International Conference on Fun with Algorithms (FUN 2018), Leibniz International Proceedings in Informatics, arXiv:1804.06515 [cs.DS], 2018.
%H Achim Flammenkamp, <a href="http://wwwhomes.uni-bielefeld.de/~achim/diss.ps.gz">Lange Perioden in Subtraktions-Spielen</a>, Dissertation, Dept. Math., University of Bielefeld, Germany.
%H Sean A. Irvine, <a href="https://github.com/archmageirvine/joeis/blob/master/src/irvine/oeis/a014/A014586.java">Java program</a> (github)
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Sprague%E2%80%93Grundy_theorem">Sprague-Grundy theorem</a>
%F a(n) = 0 iff n belongs to A030193. - _Rémy Sigrist_, May 30 2019
%o (Sage)
%o def A014586_list(max) :
%o res = []
%o for i in range(max+1) :
%o moves = list({res[i-r^2] for r in range(1, isqrt(i)+1)})
%o moves.sort()
%o k = len(moves)
%o mex = next((j for j in range(k) if moves[j] != j), k)
%o res.append(mex)
%o return res
%o A014586_list(100)
%o # _Eric M. Schmidt_, Jul 20 2013, corrected _Eric M. Schmidt_, Apr 23 2019
%Y Cf. A030193, A014587-A014589, A297963.
%K nonn
%O 0,5
%A _Achim Flammenkamp_