- 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 a, b, b, c, c, c…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 a, b, b, c, c, c…in C++.

## Problem Description

To find the Nth term of the series −

**a, b, b, c, c, c, d, d, d, d,....Nterms **

We need to find the general term of the series.

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

Input

N = 7

Output

d

## Solution Approach

To find the general term of the series, we need to closely observe the series. The series has 1 a, 2 b’s, 3 c’s, 4 d’s,... This seems to be an AP. And the Nth term is the sum of AP which a and d both 1.

Sum of AP = Nth Term = (n/2)(a+(n-1)d).

The n specifies which character is the Nth term.

Now, lets derive the value of n,

Nth Term = (n/2)*(1 + (n-1)*1) (n/2)*(1 + n - 1) (n/2)*n

$\sqrt{2\square^2}$

## Example

#include <iostream> #include <math.h> using namespace std; char findNTerm(int N) { int n = sqrt(2*N); return ((char)('a' + n)); } int main() { int N = 54; cout<<N<<"th term of the series is "<<findNTerm(N); return 0; }

## Output

54th term of the series is k

- Related Questions & Answers
- Program to find N-th term in the given series in C++
- C Program for N-th term of Geometric Progression series
- C Program for N-th term of Arithmetic Progression series
- Program to find Nth term divisible by a or b in C++
- Program to find N-th term of series 3, 6, 18, 24, … in C++
- Program to find N-th term of series 1, 3, 12, 60, 360...in C++
- 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 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…
- C/C++ Program to Find sum of Series with n-th term as n power of 2 - (n-1) power of 2
- C/C++ Program to Find the sum of Series with the n-th term as n^2 – (n-1)^2
- Program to find greater value between a^n and b^n 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++

Advertisements