Suppose we are to find the number of triangles that exist from the given figure
I found one solution that says we let $A$ equal the number of internal lines from the top vertex, $B$ equal the number of internal lines parallel to the base, using the formula below to find the number of $N$ triangles $$N=\frac{(A+1)(A+2)(B+1)}{2}$$
With $A$ equal to 2 and $B$ equal to 3, we get $N=24$ triangles.
But can somebody explain why this formula works? How exactly do I derive this?