A puzzle related to nested loops
You need to solve simple formula

$\sum_{i=1}^N\sum_{j=1}^i\sum_{k=i}^j1$

this will give you overall result of

$\frac{1}{6}N(N+1)(N+2)$

Math is easy to do here but I used Wolfram Alpha