need help in spoj TRICOUNT2 problem

can anybody please see why i am getting wrong answer in the spoj counting triangles II problem

link for problem:http://www.spoj.com/problems/TCOUNT2/

my solution in c http://ideone.com/gtdCUY

my solution in pascal http://ideone.com/O0kW1o

The correct formula for this problem is : (n(n+2)*(2n+1))/8*

1 Like
//