Sum of Series ( n ^ 2 | CPP Program to finding the sum of the nth series ; function that calculate the sum of the nth series ; using formula of the nth term ; driver function
#include <bits/stdc++.h> NEW_LINE using namespace std ; int sum_series ( int n ) { int nSquare = n * n ; return nSquare * ( nSquare - 1 ) / 4 ; } int main ( ) { int n = 2 ; cout << sum_series ( n ) << endl ; return 0 ; }