
- 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
C++ program to find n-th term of series 1, 3, 6, 10, 15, 21…
In this problem, we are given an integer N. The task is to find the n-th term in series 1, 3, 6, 10, 15, 21, 28....
Let’s take an example to understand the problem,
Input
N = 7
Output
28
Explanation
The series is 1, 3, 6, 10, 15, 21, 28...
Solution Approach
A simple solution to the problem is by finding the general term of the series. On observing the series we can see that the ith number of the series is the sum of (i-1)th term and i.
This type of number is called triangular number.
To solve the problem, we will loop till n, and for each iteration add the current index with the last element’s value. At last return the Nth elements value.
Program to illustrate the working of our solution,
Example
#include <iostream> using namespace std; int findNthTerm(int N) { int NthTerm = 0; for (int i = 1; i <= N; i++) NthTerm = NthTerm + i; return NthTerm; } int main() { int N = 8; cout<<"The "<<N<<"th term of the series is "<<findNthTerm(N); return 0; }
Output
The 8th term of the series is 36
- Related Articles
- C++ program to find n-th term of series 3, 9, 21, 41, 71…
- Program to find N-th term of series 1, 2, 11, 12, 21… 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, 6, 18, 24, … 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 0, 0, 2, 1, 4, 2, 6, 3, 8…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 1 4 15 24 45 60 92... in C++
- C++ program to find n-th term in the series 7, 15, 32, …
- 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 of series 7, 21, 49, 91, 147, 217, …… in C++
- C++ program to find n-th term of series 2, 10, 30, 68, 130 …
- Program to find N-th term of series 1, 6, 17, 34, 56, 86, 121, 162, …in C++
- C++ Programe to find n-th term in series 1 2 2 3 3 3 4
- Java Program to Find sum of Series with n-th term as n^2 – (n-1)^2

Advertisements