
- 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 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 Articles
- Program to find N-th term in the given series in C++
- Program to find N-th term of series 3, 6, 18, 24, … in C++
- C Program for N-th term of Geometric Progression series
- C Program for N-th term of Arithmetic Progression series
- 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…
- 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++

Advertisements