- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ program to find Nth number of the series 1, 6, 15, 28, 45, …..
In this problem, we are given an integer value N. Our task is to create a program to Find Nth number of the series 1, 6, 15, 28, 45, …
In the series, every element is 2 less than the mean of the previous and next element.
Let’s take an example to understand the problem,
Input
N = 5
Output
45
Solution Approach
The Nth term of the series 1, 6, 15, 28, 45, … can be found using the formula,
TN = 2*N*N - N
Program to illustrate the working of our solution,
Example
#include <iostream> using namespace std; #define mod 1000000009 int calcNthTerm(long n) { return (((2 * n * n) % mod) - n + mod) % mod; } int main(){ long N = 19; cout<<N<<"th Term of the series is "<<calcNthTerm(N); return 0; }
Output
19th Term of the series is 703
- Related Articles
- C++ program to Find Nth term of the series 1, 1, 2, 6, 24…
- C++ program to find Nth term of series 1, 4, 15, 72, 420…
- C++ program to find Nth term of the series 1, 6, 18, 40, 75, ….
- 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++
- C++ program to find Nth term of the series 1, 5, 32, 288 …
- C++ program to find Nth term of the series 1, 8, 54, 384…
- Find the Nth term of the series 14, 28, 20, 40,….. using C++
- Find the Nth term of the series 9, 45, 243,1377…in C++
- C++ program to find Nth term of the series 3, 14, 39, 84…
- C++ program to find nth term of the series 5, 2, 13 41,...
- Find the nth term of the given series 0, 0, 2, 1, 4, 2, 6, 3, 8, 4… in C++
- C++ program to find Nth term of the series 5, 13, 25, 41, 61…
- Program to find nth ugly number in C++
- C++ program to find Nth Non Fibonacci Number

Advertisements