- Related Questions & Answers
- C++ program to find Nth term of the series 5, 13, 25, 41, 61…
- C++ program to find Nth term of the series 1, 5, 32, 288 …
- C++ program to Find Nth term of the series 1, 1, 2, 6, 24…
- C++ program to find Nth term of the series 0, 2, 4, 8, 12, 18…
- C++ program to find n-th term of series 3, 9, 21, 41, 71…
- C++ program to find Nth term of the series 1, 8, 54, 384…
- C++ program to find Nth term of the series 3, 14, 39, 84…
- Program to find N-th term of series 0, 2,1, 3, 1, 5, 2, 7, 3...in C++
- C++ program to find Nth term of the series 1, 6, 18, 40, 75, ….
- C++ program to get the Sum of series: 1 – x^2/2! + x^4/4! -…. upto nth term
- C++ program to find Nth term of series 1, 4, 15, 72, 420…
- C++ program to find the sum of the series (1*1) + (2*2) + (3*3) + (4*4) + (5*5) + … + (n*n)
- Find the Nth term of the series where each term f[i] = f[i – 1] – f[i – 2] in C++
- C++ program to find nth Term of the Series 1 2 2 4 4 4 4 8 8 8 8 8 8 8 8 …
- C/C++ Program to Find the sum of Series with the n-th term as n^2 – (n-1)^2

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

In this problem, we are given an integer N. Our task is to create a program to Find Nth term of series 5, 2, 19, 13, 41, 31, 71, 57…

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

N = 5

41

The series is − 5, 2, 19, 13, 41, …

A simple approach to solve the problem is by using the general formula for the nth term of the series. The series has different formulas for even and odd values.

The Nth term is given by,

Nth term = (N-1)^2 + N, if N is even i.e N%2 == 0 Nth term = (N+1)^2 + N, if N is odd i.e N%2 != 0

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

#include <iostream> using namespace std; int calcNthTerm(int N) { if (N % 2 == 0) return ( ( (N - 1)*( N - 1) ) + N ) ; return ( ( (N + 1)*( N + 1) ) + N ) ; } int main() { int N = 7; cout<<N<<"th term of the series is "<<calcNthTerm(N); return 0; }

6th term of the series is 258

Advertisements