OFFSET
1,2
COMMENTS
The squares are numbered starting with 1 at the origin (0,0). The sequence is finite: when arriving on square number a(209) = 147, there is no free square within reach for the next move. - M. F. Hasler, Jan 26 2020
LINKS
Simon S. Gurvets, Table of n, a(n) for n = 1..209
N. J. A. Sloane and Brady Haran, The Trapped Knight, Numberphile video (2019).
Scott R. Shannon, Image showing the steps of the knight's path. A green dot marks the starting 1 square and a red dot the final square with number 147. The red dot is surrounded by eight blue dots to show the occupied neighboring squares. A yellow dots marks the smallest unvisited square with number 15. Purple dots mark the visited squares containing a prime number. The path after square 1 contains 67 primes and 141 composites.
PROG
(PARI) local(U); my(v(p)=if(bittest(U, p), [9, 0], [1-isprime(p+1), p]), nxt(x)=vecsort([v(pos(x+k))|k<-K])[1][2], K=[[(-1)^(i\2)<<(i>4), (-1)^i<<(i<5)]|i<-[1..8]], pos(x, y=x[2])=if(y>=abs(x=x[1]), 4*y^2-y-x, -x>=abs(y), 4*x^2-x-y, -y>=abs(x), (4*y-3)*y+x, (4*x-3)*x+y), xy(n, m=sqrtint(n), k=m\/2)=if(m<=n-=4*k^2, [n-3*k, -k], n>=0, [-k, k-n], n>=-m, [-k-n, k], [k, 3*k+n]), A=List(0)); until(!listput(A, nxt(xy(A[#A]))), U+=1<<A[#A]); A330008=[t+1|t<-A[^-1]] \\ M. F. Hasler, Jan 26 2020
CROSSREFS
KEYWORD
nonn,fini,full
AUTHOR
Simon S. Gurvets, Nov 26 2019
STATUS
approved