Sum of the series 1 , 3 , 6 , 10. . . ( Triangular Numbers ) | CPP program to find sum series 1 , 3 , 6 , 10 , 15 , 21. . . and then find its sum ; Function to find the sum of series ; Driver code
#include <iostream> NEW_LINE using namespace std ; int seriesSum ( int n ) { return ( n * ( n + 1 ) * ( n + 2 ) ) / 6 ; } int main ( ) { int n = 4 ; cout << seriesSum ( n ) ; return 0 ; }