Skip to content
Related Articles
Find the Nth term of the series 2 + 6 + 13 + 23 + . . .
• Last Updated : 12 Apr, 2021

Given an integer N. The task is to write a program to find the Nth term of the given series:

2 + 6 + 13 + 23 + …

Examples

Input : N = 5
Output : 36

Input : N = 10
Output : 146

Refer the article on How to find Nth term of series to know idea behind finding Nth term of any given series.
The generalized N-th term of given series is: Below is the implementation of above approach:

## C++

 //CPP program to find Nth term of the series// 2 + 6 + 13 + 23 + 36 + ...#includeusing namespace std; // calculate Nth term of given seriesint Nth_Term(int n){     return (3 * pow(n, 2) - n + 2) / (2); } // Driver codeint main(){ int N = 5;cout<

## Java

 //Java program to find Nth term of the series// 2 + 6 + 13 + 23 + 36 + ...import java.io.*; class GFG { // calculate Nth term of given seriesstatic int Nth_Term(int n){     return (int)(3 * Math.pow(n, 2) - n + 2) / (2); } // Driver code     public static void main (String[] args) {    int N = 5;    System.out.println(Nth_Term(N));    }}// This code is contributed by anuj_67..

## Python3

 # Python program to find Nth term of the series# 2 + 6 + 13 + 23 + 36 + ... # calculate Nth term of given seriesdef Nth_Term(n):    return (3 * pow(n, 2) - n + 2) // (2) # Driver codeN = 5print(Nth_Term(N))

## C#

 // C# program to find Nth term of the series// 2 + 6 + 13 + 23 + 36 + ... class GFG{ // calculate Nth term of given seriesstatic int Nth_Term(int n){         return (int)(3 * System.Math.Pow(n, 2) -                              n + 2) / (2);} // Driver codestatic void Main (){    int N = 5;    System.Console.WriteLine(Nth_Term(N));}} // This code is contributed by mits

## PHP

 

## Javascript

 
Output:
36`

Attention reader! Don’t stop learning now. Get hold of all the important mathematical concepts for competitive programming with the Essential Maths for CP Course at a student-friendly price. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

My Personal Notes arrow_drop_up