If is off the board: return . The knight has fallen off.
If and is on the board: return . No more moves needed, and you're still on the board. These two cases handle all boundaries. Off-board positions contribute nothing. On-board positions with no moves left contribute certainty. This is where recursion stops. Without it, you get infinite recursion and a stack overflow. Every recursive solution needs at least one base case.