Find n | CPP program to find n - th term of series 1 , 3 , 6 , 10 , 15 , 21. . . ; Function to find the nth term of series ; Loop to add numbers ; Driver code
#include <iostream> NEW_LINE using namespace std ; int term ( int n ) { int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) ans += i ; return ans ; } int main ( ) { int n = 4 ; cout << term ( n ) ; return 0 ; }