Find n | CPP program to find nth term ; utility function ; since first element of the series is 7 , we initialise a variable with 7 ; Using iteration to find nth term ; driver function
#include <bits/stdc++.h> NEW_LINE using namespace std ; int findTerm ( int n ) { if ( n == 1 ) return n ; else { int term = 7 ; for ( int i = 2 ; i <= n ; i ++ ) term = term * 2 + ( i - 1 ) ; return term ; } } int main ( ) { int n = 5 ; cout << findTerm ( n ) ; return 0 ; }