# Math Help - formula for counting triangles

1. ## formula for counting triangles

i want a formula for counting triangles in a big triangle
for example:

level 1=1
level 2=5
level 3=13 and son on>>>

plz help me

2. thank u very much for quick reply

When $n$ is odd , the formula is

$\binom{n+2}{3} + \frac{(n-1)(n+1)(2n+3)}{24}$

When $n$ is even , it is

$\binom{n+2}{3} + \frac{n(n+2)(2n-1)}{24}$

Or generally the number of triangles we can count is $\binom{n+2}{3} + \frac{ n(n-1)(2n+5) + 6\lfloor{ \frac{n}{2} \rfloor} }{24}$

Or $\frac{ n(n+2)(2n+1) + 2\lfloor{ \frac{n}{2} \rfloor} - n }{8}$