How many tilted squares and rectangles exists on a square grid?

Viewed 905

Given a square grid, how many unique tilted squares and rectangles exist on such a grid?

For example,

2 x 2 grid has 1 tilted square.

3 x 3 grid has 4 tilted square and 4 tilted rectangles i.e. answer is 8

Tilted means they are can be formed using vertices of the grid only.

enter image description here enter image description here

I am looking for a general formula that can be used to directly compute the number existing tilted squares and rectangles.

2 Answers
Related