Find the Nth term of the series 14 , 28 , 20 , 40 , ... . . | CPP program to find the Nth term of the series 14 , 28 , 20 , 40 , ... . . ; Function to find the N - th term ; initializing the 1 st number ; loop from 2 nd term to nth term ; if i is even , double the previous number ; if i is odd , subtract 8 from previous number ; Driver Code
#include <iostream> NEW_LINE using namespace std ; int findNth ( int N ) { int b = 14 ; int i ; for ( i = 2 ; i <= N ; i ++ ) { if ( i % 2 == 0 ) b = b * 2 ; else b = b - 8 ; } return b ; } int main ( ) { int N = 6 ; cout << findNth ( N ) ; return 0 ; }