Number Series 2

Description:

Write a program to Calculate (1*1) + (2*2) + (3*3) + (4*4) + (5*5) + ... + (n*n) series Test Case 1 Input (stdin) 10 Expected Output 385 Test Case 2 Input (stdin) 20 Expected Output 2870

Program :

#include <iostream>
using namespace std;
int main()
{
int n,i,sum=0;
  cin>>n;
  for(i=1;i<n+1;i++)
    sum=sum+i*i;
  cout<<sum;
 return 0;
}