Thursday, 8 May 2014

SPOJ Problem Set (classical) 3410. Feynman Problem code: SAMER08F

//http://www.spoj.com/problems/SAMER08F/

#include<stdio.h>
#define sqr(n) (n*n)
int main()
{
int n,temp=0;
while(1)
{
scanf("%d",&n);
if(n==0){break;}
temp=0;
while(n)
{
temp+=sqr(n);
n--;
}

printf("%d\n",temp);
}
return 0;
}


No comments:

Post a Comment