I came across this problem and after thinking a lot I could not get any idea how to calculate it. Please suggest to me the right way to calculate it.
Given a position where a knight is placed on an $n\times n$ chessboard. Find the maximum number of knights that can be placed on the board, so that no two knights attack each other.
If $n$ is even, put $n^2/2-1$ knights on the other squares of the same colour of that on which the 1st knight stands.
If $n=2k+1$ is odd, there are $2(k^2+k)+1$ of one colour (say, white) and $2(k^2+k)$ black squares. If the original knight stands on a white square, just put $2(k^2+k)$ knights on the unoccupied white squares. If the original knight stands on a black square it controls at least 3 white squares (because all corner squares are white) and so occupying the remaining $2(k^2+k)-1$ squares gets the maximum.