I thought of this problem when I was playing a game called BINGO with my friend. The game basically is like this:
Suppose $2$ people are playing the game(can be played with any no of people though). Both make a $5\cdot 5$ square grid and and fill the numbers from $1$ to $25$ in the grid at random, i.e. you can fill any numbers anywhere inside the grid. So each has his own grid and doesn't show it to other.
The first player now calls any number between $1$ to $25$. The second player then can call any of the remaining $24$ numbers. The players call the numbers alternately and keep circling the numbers on their grid. The first player to get $5$ groups of $5$ numbers across the row, column or diagonal (overlapping of numbers allowed) wins the game. Bingo!
So the final grid may look something like this:

Now, this game can easily be extended to $6\cdot 6$ or $7\cdot 7$ (you may call this BAZINGA). In genreal $n\cdot n$ grid where you have to get $n$ group of $n$ numbers across row,column or diagonal.
Finally, the question is this:
What is the minimum number of numbers to be used to make the group of numbers as required by the game. For $5\cdot 5$ grid, at least 17 entries have to be used (as in the image above). How do I generalise the result for $n\cdot n$ grid?
I think there exists a recursive relation. Although this wouldn't help me in winning the game, your solution is appreciated.
It depends on $n$ being odd or even so we'll deal with these separately:
Odd:
The minimum is as how you've drawn it for $n=5$. We have:
Cells down the first $\frac{n-1}{2}$ vertical lines: $\frac{n-1}{2} \times n$.
Extra cells across the first $\frac{n-1}{2}$ horizontal lines: $\frac{n-1}{2} \times \frac{n+1}{2}$.
Extra cells for the diagonal: $1$.
Summing: \begin{eqnarray*} \mbox{Total} &=& \frac{n-1}{2} \times n + \frac{n-1}{2} \times \frac{n+1}{2} + 1 \\ && \\ &=& \frac{n^2 - n}{2} + \frac{n^2-1}{4} + 1 \\ && \\ &=& \frac{1}{4} \left(3n^2 - 2n + 3\right) \end{eqnarray*}
This gives $17$ when $n=5$, which agrees with your answer.
Even:
The minimum is with the first $\frac{n}{2}$ cols, the first $\frac{n}{2} - 1$ rows plus the diagonal (from top-right corner). We have:
Cells down the first $\frac{n}{2}$ vertical lines: $\frac{n}{2} \times n$.
Extra cells across the first $\frac{n}{2} - 1$ horizontal lines: $\frac{n}{2} - 1 \times \frac{n}{2}$.
Extra cells for the diagonal: $1$.
Summing: \begin{eqnarray*} \mbox{Total} &=& \frac{n}{2} \times n + \left(\frac{n}{2} - 1\right) \times \frac{n}{2} + 1 \\ && \\ &=& \frac{1}{2}n^2 + \frac{1}{4}n^2 - \frac{n}{2} + 1 \\ && \\ &=& \frac{1}{4} \left(3n^2 - 2n + 4\right) \end{eqnarray*}