URI -- 1323 (Feynman)

Solution : 

Formula for n*n Grid's square sum :{ n*(n+1)*(2n+1) }/6 
Formula for n*m Grid's Rectangle sum : { n*(n+1) /2 }^2





/// Author : Shohan
/// URI 1323
/// Problem level : Easy
#include<stdio.h>
int main()
{
int ans,n,t;
while(scanf("%d",&n)==1){
if(n==0)
break;
ans=(n*(n+1)) * (2*n+1);
t=ans/6;
printf("%d\n",t);
}
return 0;
}