- Related Questions & Answers
- Program to find N-th term of series 0, 0, 2, 1, 4, 2, 6, 3, 8…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!
- C++ program to find the sum of the series (1*1) + (2*2) + (3*3) + (4*4) + (5*5) + … + (n*n)
- Program to find sum of series 1*2*3 + 2*3*4+ 3*4*5 + . . . + n*(n+1)*(n+2) in C++
- Program to find N-th term of series 1 4 15 24 45 60 92... in C++
- Program to find Sum of a Series a^1/1! + a^2/2! + a^3/3! + a^4/4! +…….+ a^n/n! in C++
- Program to find N-th term of series 3, 6, 18, 24, … in C++
- Program to find N-th term of series 4, 14, 28, 46, 68, 94, 124, 158, …..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 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 1, 2, 11, 12, 21… in C++

- 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 2, 4, 3, 4, 15… in C++.

**Problem Description** − To find the sum of the given series,

**2, 4, 3, 4, 15, 0, 14, 16 .... N terms**

We will find the formula for the general term of the series.

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

**Input** − N = 9

**Output** − 9

The increase of the values in the series is linear i.e. no square values are in the series. Also, it’s value depends on other factors too (division by 2 and 3, as 6 gives 0).

So, we will first take out N (i.e. 1, 2, 3) from their value from the series.

Series: 1*(2), 2*(2), 3*(1), 4*(1), 5*(3), 6*(0), …

On observing this we can deduct the general formula is −

**T _{n} = ( N*((N%2)+(N%3)) )**

#include <iostream> using namespace std; int findNTerm(int N) { int nthTerm = ( N*((N%2) + (N%3)) ); return nthTerm; } int main() { int N = 10; cout<<N<<"th term of the series is "<<findNTerm(N); return 0; }

10th term of the series is 10

Advertisements