C++ program to find Nth term of the series 5, 13, 25, 41, 61…


In this problem, we are given an integer N. Our task is to create a program to Find Nth term of series 5, 13, 25, 41, 61, …

Let’s take an example to understand the problem,

Input

N = 5

Output

61

Explanation

The series is − 5, 13, 25, 41, 61…

Solution Approach

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

Nth term = ( (N*N) + ((N+1)*(N+1)) )

Program to illustrate the working of our solution,

Example

 Live Demo

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

Output

7th term of the series is 113

Updated on: 15-Mar-2021

157 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements