# Program to find N-th term of series 1, 3, 12, 60, 360...in C++

C++Server Side ProgrammingProgramming

In this problem, we are given a number N. Our task is to create a Program to find N-th term of series 1, 3, 12, 60, 360...in C++.

Given Series

1, 3, 12, 60, 360, 2520 … N Terms

Let’s take an example to understand the problem,

Input − N = 6

Output − 2520

## Solution Approach:

The general term formula for this one is a bit tricky. So, the increase in the series values is huge. So, there can be a few possibilities factorial or exponentials. So, we will first consider factorial, and on observing we can see the growth half as half of the factorial values. Also, the factorial of 2 is the first term here. So, the general formula would be,

TN = ((N+1)!)/ 2

## Program to illustrate the working of our solution,

#include <iostream>
using namespace std;
int calcFact(int n){
if(n == 1){
return 1;
}
return (n*calcFact(n-1));
}
int findNTerm(int N) {
int nthTerm = ( (calcFact(N+1)) /2 );
return nthTerm;
}
int main()
{
int N = 8;
cout<<N<<"th term of the series is "<<findNTerm(N);
return 0;
}

## Output:

8th term of the series is 181440

Published on 04-May-2020 15:59:05