# How many rectangles or triangles. 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 :)

## 2 Answers

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.

• 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? – anonymous Apr 18 '15 at 12:06
• @anonymous: It is called the binomial coefficient, which you can find at Wikipedia. – user21820 Apr 18 '15 at 12:08
• 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? – anonymous Apr 18 '15 at 12:55
• Right. That's what I meant. – aNumosh Apr 18 '15 at 18:34
• In this case we are considering squares as rectangles aren't we? – 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)$$