Knight's tour / recursion
<p>Hey,
I'm trying to learn a little bit more about recursion but somehow I can't solve the knight's tour and I'm hoping someone can point out my logic error.</p>

<pre><code>class main {

    static int fsize = 5; // board size (5*5)
    static int board[][] = new int[fsize][fsize];
    static int[] move_x = {1, 2, 2, 1, -1, -2, -2, -1}; // possible moves (x-axis)
    static int[] move_y = {-2, -1, 1, 2, 2, 1, -1, -2}; // possible moves (y-axis)

    // x = current x coordinate
    // y = current y coordinate
    static void Solve(int move_number, int x, int y) {
        board[x][y] = move_number;

        // check whether the knight has been on all filds or not
        if (move_number == ((fsize * fsize) - 1)) {
            for (int i = 0; i &lt; fsize; i++) {
                for (int c = 0; c &lt; fsize; c++) {
                    System.out.printf("%3d", board[i][c]);
                }
                System.out.println("\n");
            }
        } 
        else {
            // calculate new board coordinates
            for (int i = 0; i &lt; 8; i++) {
                for (int c = 0; c &lt; 8; c++) {
                    // Check whether the new coordinates are valid or not
                    if ((x + move_x[i]) &gt;= 0 &amp;&amp; (x + move_x[i]) &lt; fsize &amp;&amp; (y + move_y[c]) &gt;= 0 &amp;&amp; (y + move_y[c]) &lt; fsize) {
                        // check whether the knight has been on this field or not (-1 = hasn't been here)
                        if (board[x + move_x[i]][y + move_y[c]] == -1) {
                            System.out.println("Move: " + move_number + "\n");
                            // Find next field
                            Solve(move_number + 1, (x + move_x[i]), (y + move_y[c]));
                        }
                    }
                }
            }
            // couldn't find a valid move
            board[x][y] = -1;
        }
    }

    public static void main(String[] args) {
        for (int i = 0; i &lt; fsize; i++) {
            for (int c = 0; c &lt; fsize; c++) {
                board[i][c] = -1;
            }
        }

        Solve(0, 0, 0);
    }
}
</code></pre>

<p>Edit: hope this is ok. I tried to run this program but couldn't get more than 22 valid moves.</p>
