# Program to find N-th term of series 7, 21, 49, 91, 147, 217, …… in C++

C++Server Side ProgrammingProgramming

In this problem, we are given a number n that denotes the nth term of the series. Our task is to create a program to find the N-th term of series 7, 21, 49, 91, 147, 217, …… in C++.

Problem Description - We will find the nth term of the series 7, 21, 49, 91, 147, 217, … and for that, we will deduce the general term of the series.

Let’s take an example to understand the problem,

Input − N = 5

Output − 147

## Solution Approach:

Let’s deduce the general term of the given series. The series is −

7, 21, 49, 91, 147, 217, …

We can see that 7 is common here,

7 * (1, 3, 7, 13, 21, 31, ...)

Here, we can observe that this series is increasing like a square series. So,

Series: 7 * (12 , (22 - 1), (33 - 2), (42 - 3), (52 - 4), (62 - 5), ....)

The general term of the series can be generalized as −

Tn = 7*(n2
- (n-1))

Using the general term formula, we can find any value of the series.

For example,

T4 = 7*((4^2) - (4-1)) = 7(16 - 3) = 91
T7 = 7*((7^2) - (7-1)) = 7(49 - 6) = 301

## Example

Live Demo

#include <iostream>
using namespace std;
int findNTerm(int N) {
int nthTerm = ( 7*((N*N) - (N - 1)) );
return nthTerm;
}
int main() {
int N = 9;
cout<<N<<"th term of the series is "<<findNTerm(N);
return 0;
}

## Output:

9th term of the series is 511
Published on 15-May-2020 13:22:31