- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures

- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces

# Program to find N-th term in the given series in C++

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++.

## Problem Description

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,**

## Example 1

**Input**

N = 6

**Output**

9

## Example 2

**Input**

N = 13

**Output**

64

## Solution Approach

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.**

## Example

#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); }

## Output

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

- Related Articles
- 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 …
- 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++
- 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 1, 3, 12, 60, 360...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++
- Program to find N-th term of series 9, 23, 45, 75, 113… in C++
- C++ program to find n-th term of series 2, 10, 30, 68, 130 …
- C++ program to find n-th term of series 3, 9, 21, 41, 71…
- Program to find N-th term of series 7, 21, 49, 91, 147, 217, …… in C++
- C Program for N-th term of Geometric Progression series