# 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


Updated on: 03-Oct-2020

64 Views

##### Kickstart Your Career

Get certified by completing the course