In this problem, we are given a number N. Our task is to create a program to find N-th term of series 3, 12, 29, 54, 87, … in C++.
The series is
3, 12, 29, 54, 87, 128, .... N-Terms
Input − N = 5
Output − 87
Let’s deduce the general term of the given series. The series is −
3, 12, 29, 54, 87, 128, ....
The general term of this series is
Tn = 4(n2 ) - 3*n + 2
Using the general term formula, we can find any value of the series.
For example,
T8 = 4*(82 ) - 3*8 + 2 T8 = 234
#include <iostream> using namespace std; int findNTerm(int N) { int nthTerm = ( (4*N*N) - (3*N) + 2 ); return nthTerm; } int main() { int N = 7; cout<<N<<"th term of the series is "<<findNTerm(N); return 0; }
7th term of the series is 177