
- 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 3, 6, 18, 24, … 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 3, 6, 18, 24, … in C++.
Problem Description − To find the Nth term of the series −
3, 6, 18, 24, 45, 54, 84 … N Terms
We need to find the general formula for the given series.
Let’s take an example to understand the problem,
Input − N = 10
Output − 150
Solution Approach:
To find the general term of the series, we will first observe the series and check all the possible generalizations of the series. Like, 3 is common in all but as you go-ahead, you will find that it will not provide any result.
Here, we can also take out the term n i.e. 1, 2, 3. From their values in series to give it a new form. Further checking the remaining value, we will get the following general formula.
General Term of the series
Tn = (n*((n/2) + ((n%2) *2) + 5))
Example
#include <iostream> using namespace std; int findNTerm(int N) { int nthTerm = ( N*((N/2)+ ((N%2)*2) + N) ); return nthTerm; } int main() { int N = 7; cout<<N<<"th term of the series is "<<findNTerm(N); return 0; }
Output:
7th term of the series is 84
- Related Articles
- C++ program to find n-th term of series 1, 3, 6, 10, 15, 21…
- Program to find N-th term of series 1 4 15 24 45 60 92... in C++
- Program to find N-th term of series 0, 0, 2, 1, 4, 2, 6, 3, 8…in C++
- 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, 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 0, 2,1, 3, 1, 5, 2, 7, 3...in C++
- Program to find N-th term in the given series in C++
- Program to find N-th term of series 1, 6, 17, 34, 56, 86, 121, 162, …in C++
- Program to find N-th term of series 3, 12, 29, 54, 86, 128, 177, 234, ….. in C++
- C++ Programe to find n-th term in series 1 2 2 3 3 3 4
- C++ program to find n-th term in the series 7, 15, 32, …

Advertisements