TITLE: How to calculate the number of paths of minimum length possible a knight can take to get from one corner of a chess board to the opposite one?
QUESTION [9 upvotes]: I've written a small Python script to give me the least number of moves it takes a knight to get from one square to any other on a $n{*}n$ chess board.
But then I've wondered how many paths the knight can take from one corner to the opposite one that use the minimal number of moves (i.e. on any $n{*}n$ board in $2*\Big\lceil{\frac{n-1}{3}}\Big\rceil$ moves, e.g. on a $8{*}8$ board in 6 moves).
So, I added another function to the code to "calculate" exactly that number by doing all possible paths from the opposite corner to the start where every step involves a decrease in the minimum number of moves needed to get to that square (which is calculated beforehand with the other function I mentioned at the beginning).
By now I have values for all $n$ from $1$ to $34$ (attached the list below). As you can see, the values get pretty big, which means it takes really long to calculate them using "brute-force" methods. Do you know of any way to calculate that number without the need of a computer trying all the possibilities?

REPLY [2 votes]: The sequence $a(n), n\geq 0$
\begin{align*}
1,0,2,2,8,4,6,\color{blue}{108},40,20,858,252,70,5\,596,1\,344,252,\ldots\tag{1}
\end{align*}
giving the wanted number of shortest knight paths in an $(n\times n)$ board from the left bottom corner to the top right corner is stored as A120399 in OEIS.

The following formula for $a(n), n>3$ is stated: Let \begin{align*}
K=K(n)=2\left\lfloor\frac{n+1}{3}\right\rfloor
\end{align*}
be the shortest path length. Then $a(n), n>3$ is given as
\begin{align*}
a(n)&=2(K-2)\binom{K-1}{K/2-2}&n\equiv0\mod(3)\\
a(n)&=\binom{K}{K/2}&n\equiv1\mod(3)\\
a(n)&=(K-2)(K-3)\binom{K-2}{K/2-1}\\
&\qquad+2\left((K-2)\binom{K-1}{K/2-2}-2\binom{K-2}{K/2-3}\right)&n\equiv2\mod(3)\\
&\qquad+2\left(\binom{K-2}{2}\binom{K-2}{K/2-4}-2\binom{K-3}{K/2-5}\right)
\end{align*}

Example: ($n=8$)
We calculate the number of shortest paths for the $(8\times 8)$ board. We obtain
\begin{align*}
K=K(8)=2\left\lfloor\frac{8+1}{3}\right\rfloor=6
\end{align*}
Since $8\equiv2\mod(3)$ we calculate
\begin{align*}
\color{blue}{a(8)}&=4\cdot 3\binom{4}{2}+2\left(4\binom{5}{1}-2\binom{4}{0}\right)\\
&=12\cdot 6 + 2\left(4\cdot 5 -2\right)\\
&=72+36\\
&\,\,\color{blue}{=108}
\end{align*}
in accordance with the blue marked value in the sequence (1). Note the binomial coefficient is set equal to $0$ if the lower index is negative.