# formula for counting triangles

• Jun 30th 2010, 04:58 AM
mido22
formula for counting triangles
i want a formula for counting triangles in a big triangle
for example:
http://www.spoj.pl/content/duonghanguyen:tricount.png
level 1=1
level 2=5
level 3=13 and son on>>>

plz help me
• Jun 30th 2010, 05:16 AM
Zaph
• Jun 30th 2010, 05:37 AM
mido22
thank u very much for quick reply
• Jul 1st 2010, 04:29 PM
Wilmer
• Jul 1st 2010, 07:19 PM
simplependulum
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}$