
- 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 1 4 15 24 45 60 92... 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 1 4 15 24 45 60 92... in C++.
Problem description − To find the nth term of the series −
1, 4, 15, 24, 45, 60, 92, 112 … N terms
We will find the general formula for the series.
Let’s take an example to understand the problem,
Input − N = 6
Output − 60
Solution Approach,
The general term of the series is based on whether the value of N is even or odd. This type of series is a bit complex to recognize but once you think of series as two different for even and odd, it is quite easy to find the general term.
The general term is −
TN = ((2 * (N^2)) - N), if n is odd. TN = (2 * ((N^2) - N)), if n is even.
Program to illustrate the working of our solution,
#include <iostream> using namespace std; int findNTerm(int N) { if (N%2 == 0) return ( 2*((N*N)-N) ); return ( (2*(N*N)) - N ); } int main() { int N = 10; cout<<N<<"th term of the series is "<<findNTerm(N); return 0; }
Output:
10th term of the series is 180
- Related Articles
- Program to find N-th term of series 2, 4, 3, 4, 15… in C++
- Program to find N-th term of series 1, 3, 12, 60, 360...in C++
- C++ program to find n-th term of series 1, 3, 6, 10, 15, 21…
- Program to find N-th term of series 3, 6, 18, 24, … in C++
- C++ program to find n-th term in the series 7, 15, 32, …
- Program to find N-th term of series 9, 23, 45, 75, 113… in C++
- C++ program to find n-th term of series 1, 4, 27, 16, 125, 36, 343...
- C++ program to find Nth term of series 1, 4, 15, 72, 420…
- Program to find N-th term of series 1, 2, 11, 12, 21… in C++
- Program to find N-th term of series 0, 0, 2, 1, 4, 2, 6, 3, 8…in C++
- Java Program to Find sum of Series with n-th term as n^2 – (n-1)^2
- Program to find N-th term of series 0, 10, 30, 60, 99, 150, 210, 280...in C++
- Program to find N-th term of series 0, 9, 22, 39, 60, 85, 114, 147, …in C++
- C++ Programe to find n-th term in series 1 2 2 3 3 3 4
- Program to find N-th term in the given series in C++

Advertisements