Close

Number of rectangles

Given a number of unit squares (1 x 1). How many different rectangles can be formed with them?

For example let us consider 4 units. We can form 5 different rectangles like the following. Two rectangles are considered same if they are oriented in a different way but same dimensions.


Basically we have to arrange 1 to N-1 units to form rectangles of different dimensions.
This boils down to finding the sum of the number of pairs factors of 1 to N numbers.

Here is the C++ program to do that.

Leave a Reply

Your email address will not be published. Required fields are marked *