mneeti wrote:

Is there any direct formula to calculate it?

Thanks in advance !

There is, in fact.

What is the number of k x k squares that can be formed from a n x n board?

(n-k+1)^2, so in that case (6-3+1)^2=16.

The logic is as follows:

-horizontally, you are going to need k boxes of the board for your little k x k square, so n-k boxes will still be "free" (out of the kxk square). Hence, you need to count the number of ways you can allocate those "free" boxes to the left and to the right of your kxk square. You could:

- put 0 box on the left and all the free n-k boxes on the right

- put 1 box on the left and all the free n-k-1 boxes on the right

- ......

- put n-k boxes on the left and 0 box on the right

You can see that there are n-k+1 ways of doing so.

-vertically, the same logic applies.

You therefore end up with the formula above (would also work in higher number of spatial dimensions, eg with cubes, by replacing the ^2 by ^3 in that case.)

Of course, it's better to be able to think about this process and derive the logic during the exam than to use a pre-made formula, but I guess the exercise of deriving a general formula to add layers of complexity is always a fun and rewarding exercise