text: Sum of the first N terms of the series 2 , 10 , 30 , 68 , ... . | C ++ program to find sum of first n terms ; Function to calculate the sum ; Driver code ; number of terms to be included in the sum ; find the Sum
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; int calculateSum ( int n ) { return n * ( n + 1 ) / 2 + pow ( ( n * ( n + 1 ) / 2 ) , 2 ) ; } int main ( ) { int n = 3 ; cout << " Sum ▁ = ▁ " << calculateSum ( n ) ; return 0 ; }