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.
%I A321172 #98 Jun 29 2025 17:46:31 %S A321172 1,1,0,1,2,6,1,0,14,0,1,4,37,154,1072,1,0,92,0,5320,0,1,8,236,1696, %T A321172 32675,301384,4638576,1,0,596,0,175294,0,49483138,0,1,16,1517,18684, %U A321172 1024028,17066492,681728204,13916993782,467260456608 %N A321172 Triangle read by rows: T(m,n) = number of Hamiltonian cycles on m X n grid of points (m >= 2, 2 <= n <= m). %C A321172 Orientation of the path is not important; you can start going either clockwise or counterclockwise. Paths related by symmetries are considered distinct. %C A321172 The m X n grid of points when drawn forms a (m-1) X (n-1) rectangle of cells, so m-1 and n-1 are sometimes used as indices instead of m and n (see, e. g., Kreweras' reference below). %C A321172 These cycles are also called "closed non-intersecting rook's tours" on m X n chess board. %H A321172 Huaide Cheng, <a href="/A321172/b321172.txt">Rows n=2..17 of triangle, flattened</a> %H A321172 Robert Ferréol, <a href="/A321172/a321172.gif">The T(4,5)=14 hamiltonian cycles on 4 X 5 square grid of points</a>; the T(5,6) = 154 cycles on 5 X 6 grid <a href="/A321172/a321172_1.gif">are reduced to 44 different forms</a>. %H A321172 Germain Kreweras, <a href="https://doi.org/10.1016/0195-6698(92)90005-K">Dénombrement des cycles hamiltoniens dans un rectangle quadrillé</a>, European Journal of Combinatorics, Volume 13, Issue 6 (1992), page 476. %H A321172 Robert Stoyan and Volker Strehl, <a href="https://www.emis.de/journals/SLC/wpapers/s34erlangen.html">Enumeration of Hamiltonian Circuits in Rectangular Grids</a>, Séminaire Lotharingien de Combinatoire, B34f (1995), 21 pp. %H A321172 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/GridGraph.html">Grid Graph</a>. %H A321172 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/HamiltonianCycle.html">Hamiltonian Cycle</a>. %F A321172 T(m,n) = T(n,m). %F A321172 T(2m+1,2n+1) = 0. %F A321172 T(2n,2n) = A003763(n). %F A321172 T(n,n+1) = T(n+1,n) = A222200(n). %F A321172 G. functions , G_m(x)=Sum {n>=0} T(m,n-2)*x^n after Stoyan's link p. 18 : %F A321172 G_2(x) = 1/(1-x) = 1+x+x^2+... %F A321172 G_3(x) = 1/(1-2*x^2) = 1+2*x^2+4*x^4+... %F A321172 G_4(x) = 1/(1-2*x-2*x^2+2*x^3-x^4) = 1+2*x+6*x^2+... %F A321172 G_5(x) = (1+3*x^2)/(1-11*x^2-2*x^6) = 1+14*x^2+154*x^4+... %e A321172 T(5,4)=14 is illustrated in the links above. %e A321172 Table starts: %e A321172 ================================================================= %e A321172 m\n| 2 3 4 5 6 7 8 %e A321172 ---|------------------------------------------------------------- %e A321172 2 | 1 1 1 1 1 1 1 %e A321172 3 | 1 0 2 0 4 0 8 %e A321172 4 | 1 2 6 14 37 92 236 %e A321172 5 | 1 0 14 0 154 0 1696 %e A321172 6 | 1 4 37 154 1072 5320 32675 %e A321172 7 | 1 0 92 0 5320 0 301384 %e A321172 8 | 1 8 236 1696 32675 301384 4638576 %e A321172 The table is symmetric, so it is completely described by its lower-left half. %o A321172 (Python) %o A321172 # Program due to Laurent Jouhet-Reverdy %o A321172 def cycle(m, n): %o A321172 if (m%2==1 and n%2==1): return 0 %o A321172 grid = [[0]*n for _ in range(m)] %o A321172 grid[0][0] = 1; grid[1][0] = 1 %o A321172 counter = [0]; stop = m*n-1 %o A321172 def run(i, j, nb_points): %o A321172 for ni, nj in [(i-1, j), (i+1, j), (i, j+1), (i, j-1)] : %o A321172 if 0<=ni<=m-1 and 0<=nj<=n-1 and grid[ni][nj]==0 and (ni,nj)!=(0,1): %o A321172 grid[ni][nj] = 1 %o A321172 run(ni, nj, nb_points+1) %o A321172 grid[ni][nj] = 0 %o A321172 elif (ni,nj)==(0,1) and nb_points==stop: %o A321172 counter[0] += 1 %o A321172 run(1, 0, 2) %o A321172 return counter[0] %o A321172 L=[];n=7#maximum for a time < 1 mn %o A321172 for i in range(2,n): %o A321172 for j in range(2,i+1): %o A321172 L.append(cycle(i,j)) %o A321172 print(L) %Y A321172 Row/column k=4..12 are: (with interspersed zeros for odd k): A006864, A006865, A145401, A145416, A145418, A160149, A180504, A180505, A213813. %Y A321172 Cf. A003763 (bisection of main diagonal), A222200 (subdiagonal), A231829, A270273, A332307. %Y A321172 T(n,2n) gives A333864. %K A321172 nonn,tabl %O A321172 2,5 %A A321172 _Robert FERREOL_, Jan 10 2019 %E A321172 More terms from _Pontus von Brömssen_, Feb 15 2021