- Related Questions & Answers
- Program to find N-th term of series 3 , 5 , 21 , 51 , 95 , … in C++
- Program to find N-th term of series 7, 21, 49, 91, 147, 217, …… in C++
- Program to find N-th term of series 2, 12, 28, 50, 77, 112, 152, 198, …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 3, 12, 29, 54, 87, … in C++
- Program to find N-th term of series 0, 0, 2, 1, 4, 2, 6, 3, 8…in C++
- Program to find N-th term of series 2, 4, 3, 4, 15… in C++
- Java Program to Find sum of Series with n-th term as n^2 – (n-1)^2
- 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 N-th term of series 3, 12, 29, 54, 86, 128, 177, 234, ….. in C++
- Program to find N-th term of series 0, 11, 28, 51, 79, 115, 156, 203, …In C++
- Python Program for Find sum of Series with the n-th term as n^2 – (n-1)^2
- Program to find N-th term of series 3, 6, 18, 24, … in C++
- C++ program to find the sum of the series 1 + 1/2^2 + 1/3^3 + …..+ 1/n^n

- 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 of series 1, 2, 11, 12, 21… in C++.

To find the Nth term of the series −

1, 2, 11, 12, 21, 22, 111, 112, .... Nterms

We will find the general term of the series.

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

N = 8

112

To derive the general term, we need to closely observe the series. In this series, we can see that there are only 1’s and 2’s in the value. And every term is an alternation of 1 and 2. So, the general term will be,

$$T_{(N)}=T_{(n/2)}*10 + 1,\:if\:N\:is\:odd.$$

$$T_{(N)}= T_{((n/2)-1)}*10 + 2, if\:N\:is\:even.$$

#include <iostream> using namespace std; int findNTerm(int N) { if(N == 1) return 1; if(N == 2) return 2; int value; if(N%2 == 0){ value = (findNTerm((N/2)-1)*10) + 2; } else value = (findNTerm((N/2))*10) + 1; return value; } int main() { int N = 12; cout<<N<<"Th term of the series is "<<findNTerm(N); return 0; }

12Th term of the series is 212

Advertisements