enter image description here

I have come across numerous questions where I am given the picture such as the above one been asked "how many rectangles are there?". I have even come across some slightly different images that instead of rectangles you are supposed to find the number of triangles. Well, I was thinking whether there is any formula or strategy that is used to solve these problems without having to manually count every shape.

Help would be appreciated.

Thank you :)


To have a rectangle, you need 2 horizontal lines and 2 vertical lines. So for your given picture, there are $5\choose 2$ choices for two vertical lines. Also $4\choose 2$ choices for horizontal lines. So there are ${5 \choose 2}\times{4\choose2}$ rectangles in total.

The strategy is to find a way to categorize the things you want to count. Various problems will require various tricks, but you can gain experience by trying to solve them by your own.

  • $\begingroup$ What does the 5 over the 2 in brackets and 4 over the 2 in brackets mean. Is it just another way to show that it is a combination? $\endgroup$ – anonymous Apr 18 '15 at 12:06
  • $\begingroup$ @anonymous: It is called the binomial coefficient, which you can find at Wikipedia. $\endgroup$ – user21820 Apr 18 '15 at 12:08
  • $\begingroup$ So basically, what you're saying is that we can choose 2 of 5 possible x-coordinates 10 ways, and we can choose 2 from the 4 y-coordinates in 6 ways. Thus, this gives a total of 10×6=60 rectangles. Is that right? $\endgroup$ – anonymous Apr 18 '15 at 12:55
  • $\begingroup$ Right. That's what I meant. $\endgroup$ – aNumosh Apr 18 '15 at 18:34
  • 1
    $\begingroup$ In this case we are considering squares as rectangles aren't we? $\endgroup$ – kgkmeekg Apr 15 '16 at 5:08

I have found also this answer: $$\left(\sum_{i=1}^{\text{Length}+1} i\right)\cdot\left(\sum_{i=1}^{\text{Width}+1} i\right)$$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.