
I got a question yesterday, to count the number of triangles in the above figure. I counted them, then thought about a formula to do the counting. I can't do that. Can someone show me how?

I got a question yesterday, to count the number of triangles in the above figure. I counted them, then thought about a formula to do the counting. I can't do that. Can someone show me how?
Its rather easy, once you think about it.
Let $h$ be the number of horizontal lines, and $v$ the number of non-horizontal lines. To form a triangle, you need to choose two non-horizontal lines, and one horizontal as base.
You can choose non-horizontal lines in $^v\text C_2={{v(v-1)}\over{2}}$ ways. Any of the horizontal lines may be selected in $^h\text C_1=h$ ways.
So, the total number of triangles is ${{^v\text C_2}\cdot{^h\text C_1}}$
Which is ${{{v(v-1)}\over{2}}\cdot{h}}$
And thus
$${{hv(v-1)}\over{2}}$$
P.S. In your figure, it is ${{5×6×5}\over2}=75$