Saturday, October 22, 2016

UVA 12149 - Feynman

#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
   int n;
   while(cin >>n && n){
    int total = 0;
    for (int i = 2; i <= n; ++i)
    {
        total+=(i*i);
    }
    cout << total+1 << '\n';
   }

return 0;
}

No comments:

Post a Comment