Program to find N-th term of series 9, 23, 45, 75, 113… in C++


In this problem, we are given an integer n that denotes the nth term of the series. Our task is to create a program to find N-th term of series 9, 23, 45, 75, 113… in C++.

Problem Description − Here, we need to find the nth term of the series for which we will be finding the general term of the series.

The series is 9, 23, 45, 75, 113, 159, 213, …

Let’s take an example to understand the problem,

Input − n = 5

output − 159

Solution Approach,

The general term of the given series is

Nth term = ( ((2*N + 3)^2) - 2*N)

Example

 Live Demo

#include <iostream>
using namespace std;
int calcNTerm(int N) {
   int nthTerm = ( (2*N + 3)*(2*N + 3) - (2*N) );
   return nthTerm;
}
int main() {
   int n = 6;
   cout<<"Nth term of the series is "<<calcNTerm(n);
   return 0;
}

Output:

Nth term of the series is 213

Updated on: 01-Oct-2020

150 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements