# C++ program to find Nth term of the series 1, 5, 32, 288 …

C++Server Side ProgrammingProgramming

#### C in Depth: The Complete C Programming Guide for Beginners

45 Lectures 4.5 hours

#### Practical C++: Learn C++ Basics Step by Step

Most Popular

50 Lectures 4.5 hours

#### Master C and Embedded C Programming- Learn as you go

66 Lectures 5.5 hours

In this problem, we are given an integer N. Our task is to create a program to Find Nth term of series 1,5, 32, 288 ...

Let’s take an example to understand the problem,

## Input

N = 4

## Output

288

## Explanation

4th term − (4^4) + (3^3) + (2^2) + (1^1) = 256 + 27 + 4 + 1 = 288

## Solution Approach

A simple approach to solve the problem is by using the general formula for the nth term of the series. The formula for,

Nth term = ( N^N ) + ( (N-1)^(N-1) ) + … + ( 2^2 ) + ( 1^1 )

Program to illustrate the working of our solution,

## Example

Live Demo

#include <iostream>
using namespace std;
int calcNthTerm(int N) {
if (N <= 1)
return 1;
int factorial = 1;
for (int i = 1; i < N; i++)
factorial *= i;
return factorial;
}
int main() {
int N = 8;
cout<<N<<"th term of the series is "<<calcNthTerm(N);
return 0;
}

## Output

8th term of the series is 5040