Pages

Sunday 18 November 2012

UVA - 12149 - Feynman

#include <stdio.h>

int main () {
    int x,i,temp;
    int arr[101];
    arr[0]=0;
    for(i=1,temp=1;i<101;i++,temp=i*i){
        arr[i]=arr[i-1]+temp;
    }
    while(1){
        scanf("%d", &x);
        if(x==0)
            break;
        printf("%d\n",arr[x]);
    }
    return 0;
}

No comments:

Post a Comment