- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

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

# Program to find N-th term of series 0, 0, 2, 1, 4, 2, 6, 3, 8…in C++

In this problem, we are given a number N. Our task is to create a program to find N-th term of series 0, 0, 2, 1, 4, 2, 6, 3, 8…in C++.

## Problem description

To find the Nth term of the given series−

0, 0, 2, 1, 4, 2, 6, 3, 8 .... N Terms

We will find the general term of the series.

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

## Input

N = 8

## Output

3

## Solution Approach

To find the general term of the series, we need to closely observe the series. This series is a bit difficult to recognize as it is a mixture of two series. One series at even positions and one series at odd positions.

Odd Series− 0, 2, 4, 6, 8, 10, 12,....

Even Series− 0, 1, 2, 3, 4, 5, 6,....

Here,

If the nth term of the series is

Odd, the value is (n-1).

Even, the value is $T_{(n-1)}/2$

## Example

#include using namespace std; int findNTerm(int N) { if (N % 2 == 0) return findNTerm(N-1)/2; else { return (N-1); } } int main(){ int N = 13; cout<<N<<"th term of the series is "<<findNTerm(N)<<endl; }

## Output

13th term of the series is 12

- Related Questions & Answers
- Find the nth term of the given series 0, 0, 2, 1, 4, 2, 6, 3, 8, 4… in C++
- C++ Programe to find n-th term in series 1 2 2 3 3 3 4
- Program to find N-th term of series 0, 2,1, 3, 1, 5, 2, 7, 3...in C++
- Sum of the series 2 + (2+4) + (2+4+6) + (2+4+6+8) + ... + (2+4+6+8+...+2n) in C++
- Program to find N-th term of series 2, 4, 3, 4, 15… in C++
- Sum of the series 1 + (1+2) + (1+2+3) + (1+2+3+4) + ... + (1+2+3+4+...+n) 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 …
- n-th number with digits in {0, 1, 2, 3, 4, 5} in C++
- C++ program to find Nth term of the series 0, 2, 4, 8, 12, 18…
- Sum of the series 2^0 + 2^1 + 2^2 +...+ 2^n in C++
- C++ Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! + …… n/n!
- C++ program to find the sum of the series 1/1! + 2/2! + 3/3! + 4/4! +…….+ n/n!
- Python Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +…….+ n/n!
- Java Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +…….+ n/n!
- Find Sum of Series 1^2 - 2^2 + 3^2 - 4^2 ... upto n terms in C++

Advertisements