C++ program to find Nth term of the series 3, 14, 39, 84…



In this problem, we are given an integer N. Our task is to create a program to Find Nth term of series 3, 14, 39, 84…

Let’s take an example to understand the problem,

Input

N = 4

Output

84

Explanation

4th term − ( (4*4*4) + (4*4) + 4 ) = 64 + 16 + 4 = 84

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) + (N*N) + (N))

Program to illustrate the working of our solution,

Example

 Live Demo

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

Output

6th term of the series is 258
Updated on: 2021-03-15T10:42:43+05:30

161 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements