- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# C++ program to find n-th term in the series 9, 33, 73,129 â€¦

In this problem, we are given an integer N. The task is to find n-th term in series 9, 33, 73, 129....

**Let’s take an example to understand the problem,**

## Input

N = 4

## Output

129

## Explanation

The series upto nth term is 9, 33, 73, 129...

## Solution Approach

The solution to the problem lies in finding the nth term of the series. We will find it mathematically and then apply the general term formula to our program.

First let’s subtract the series by shifting it by one.

Sum = 9 + 33 + 73 + … + t(n-1) + t(n) - Sum = 9 + 33 + 73 + …. + t(n-1) + t(n) 0 = 9 + ((33- 9) + (73 - 33) + … + (tn) - t(n-1)) - t(n) t(n) = 9 + (24 + 40 + 56 + …. ) 24 + 40 + 56 + …. is an A.P. series with common difference 16.

This makes the general term,

t(n) = 9 + [ ((n-1)/2)*(2*(24) + (n-1-1)*16) ]

$$t(n)=9+[\left(\frac{n-1}{2}\right)*((2*24)+(n-2)*16)]$$ $$t(n)=9+[\left(\frac{n-1}{2}\right)*((2*24)+(n-2)*8)]$$

t(n) = 9 + [(n - 1) * ((24) + (n - 2) * 8]

t(n) = 9 + [(n - 1) * ((24) + 8n - 16]

t(n) = 9 + [(n - 1) * (8 + 8n]

t(n) = 9 + 8 * [(n - 1) * (n + 1)]

t(n) = 9 + 8 * [n^{2} - 1^{2}]

t(n) = 9 + 8 * n^{2} - 8

t(n) = 8 * n^{2} + 1

**Program to illustrate the working of our solution,**

## Example

#include <iostream> using namespace std; int findNthTerm(int n) { return (8*n*n) + 1 ; } int main(){ int n = 12; cout<<"The series is 9, 33, 73, 129...\n"; cout<<n<<"th term of the series is "<<findNthTerm(n); return 0; }

## Output

The series is 9, 33, 73, 129... 12th term of the series is 1153