- Related Questions & Answers
- C++ program to find n-th term in the series 7, 15, 32, …
- C++ program to find n-th term in the series 9, 33, 73,129 …
- C Program for N-th term of Geometric Progression series
- C Program for N-th term of Arithmetic Progression series
- Program to find N-th term of series 1, 3, 12, 60, 360...in C++
- Program to find N-th term of series 3, 6, 18, 24, … in C++
- Program to find N-th term of series a, b, b, c, c, c…in C++
- C/C++ Program to Find the sum of Series with the n-th term as n^2 – (n-1)^2
- C++ program to find n-th term of series 3, 9, 21, 41, 71…
- C++ program to find n-th term of series 2, 10, 30, 68, 130 …
- Program to find N-th term of series 3, 5, 33, 35, 53… in C++
- Program to find N-th term of series 1, 2, 11, 12, 21… in C++
- Program to find N-th term of series 2, 4, 3, 4, 15… in C++
- Program to find N-th term of series 3 , 5 , 21 , 51 , 95 , … in C++
- Program to find N-th term of series 3, 12, 29, 54, 87, … in C++

- 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 a number N. Our task is to create a program to find N-th term in the given series in C++.

To find the sum of the given series −

1, 1, 2, 3, 4, 9, 8, 27, 16, 81, 32, 243, 64, 729, 128, 2187, 256, ... NTerms

We will find the general term of the series.

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

**Input**

N = 6

**Output**

9

**Input**

N = 13

**Output**

64

To solve the problem, we need to carefully observe the series. As it is, a mixture series and these types of series are difficult to recognize initially but later it is easy to work with.

The series is a mixture series of the at type,

At even places, the index of the series is a series of powers of 3.

At odd places, the index of the series is a series of powers of 2.

The general term is derived as −

**T_{N}=2^{N/2}, if N is odd.**

**3^{N/2}, if N is even.**

#include <iostream> #include <math.h> using namespace std; int findLCM(int a, int b) { int LCM = a, i = 2; while(LCM % b != 0) { LCM = a*i; i++; } return LCM; } int findNTerm(int N) { if(N%2 == 0){ return pow(3, ((N-1)/2)); } else return pow(2, (N/2)); } int main() { int N = 9; cout<<N<<"th term of the series is "<<findNTerm(N)<<endl; N = 14; cout<<N<<"th term of the series is "<<findNTerm(N); }

9th term of the series is 16 14th term of the series is 729

Advertisements