Program to find sum of series 1 + 2 + 2 + 3 + 3 + 3 + . . . + n | C ++ Program to find sum of series 1 + 2 + 2 + 3 + . . . + n ; Function to find sum of series . ; Driver function
#include <bits/stdc++.h> NEW_LINE using namespace std ; int sumOfSeries ( int n ) { return ( n * ( n + 1 ) * ( 2 * n + 1 ) ) / 6 ; } int main ( ) { int n = 10 ; cout << sumOfSeries ( n ) ; return 0 ; }