In this tutorial, we will be discussing a program to find N-th term of series 1, 6, 17, 34, 56, 86, 121, 162, …
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
#include <iostream>
#include <math.h>
using namespace std;
//calculating nth term of given series
int nthTerm(int n) {
return 3 * pow(n, 2) - 4 * n + 2;
}
int main() {
int N = 4;
cout << nthTerm(N) << endl;
return 0;
}Output
34