
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Program to find N-th term of series 0, 11, 28, 51, 79, 115, 156, 203, …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 0, 11, 28, 51, 79, 115, 156, 203, … In C++.
Problem Description − To find the Nth terms of the series −
0, 11, 28, 51, 79, 115, 156, 203, … N-th term.
Let’s take an example to understand the problem,
Input − N = 5
Output − 79
Solution Approach:
The general formula for nth term of the series is −
Tn = 3*(N*N) + 2*N - 5
Program to illustrate the working of our solution,
#include <iostream> using namespace std; int findNTerm(int N) { int nthTerm = ( (3*N*N) + 2*N - 5); return nthTerm; } int main() { int N = 9; cout<<N<<"th term of the series is "<<findNTerm(N); return 0; }
Output:
9th term of the series is 256
Advertisements