Find the sum of n terms of the series 1 , 8 , 27 , 64 ... . | C ++ program to find the sum of n terms ; Function to calculate the sum ; Return total sum ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int calculateSum ( int n ) { return pow ( n * ( n + 1 ) / 2 , 2 ) ; } int main ( ) { int n = 4 ; cout << calculateSum ( n ) ; return 0 ; }