Program to find N-th term of series 0, 7, 8, 33, 51, 75, 102, 133...in C++

C++Server Side ProgrammingProgramming

In this tutorial, we will be discussing a program to find N-th term of series 0, 7, 8, 33, 51, 75, 102, 133...

For this, we will be provided with a number. Our task is to find the term for the given series at that particular position.

Example

Live Demo

#include <iostream>
#include <math.h>
using namespace std;
//calculating nth term of series
int nthTerm(int n) {
return 2 * pow(n, 2) + n - 3;
}
int main() {
int N = 4;
cout << nthTerm(N) << endl;
return 0;
}

Output

33
Published on 04-May-2020 12:23:46