# Find the Nth term of the series 2 + 6 + 13 + 23 + . . .

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 + ... ` `#include<bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// calculate Nth term of given series ` `int` `Nth_Term(` `int` `n) ` `{ ` ` ` `return` `(3 * ` `pow` `(n, 2) - n + 2) / (2); ` ` ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `int` `N = 5; ` `cout<<Nth_Term(N)<<endl; ` ` ` `} ` |

*chevron_right*

*filter_none*

## 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 series ` `static` `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.. ` |

*chevron_right*

*filter_none*

## Python3

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

*chevron_right*

*filter_none*

## C#

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

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP program to find ` `// Nth term of the series ` `// 2 + 6 + 13 + 23 + 36 + ... ` ` ` `// calculate Nth term of given series ` `function` `Nth_Term(` `$n` `) ` `{ ` ` ` `return` `(3 * pow(` `$n` `, 2) - ` `$n` `+ 2) / (2); ` `} ` ` ` `// Driver code ` `$N` `= 5; ` `echo` `(Nth_Term(` `$N` `)); ` ` ` `// This code is contributed ` `// by Sach_Code ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

36

GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details

## Recommended Posts:

- Find Nth term of the series where each term differs by 6 and 2 alternately
- Find the Nth term of the series where each term f[i] = f[i - 1] - f[i - 2]
- Find n-th term in the series 7, 15, 32, ...
- Find the Nth term of the series 2, 15, 41, 80, 132...
- Find n-th term in the series 9, 33, 73,129 ...
- Find the Nth term of the series 14, 28, 20, 40,.....
- Find the Nth term of the series 1 + 2 + 6 + 15 + 31 + 56 + ...
- Find the nth term of the given series
- Find Nth term of the series 0, 6, 0, 12, 0, 90...
- Find Nth term of the series 3, 14, 39, 84...
- Find sum of Series with n-th term as n^2 - (n-1)^2
- Find Nth term of the series 2, 3, 10, 15, 26....
- Find the Nth term in series 12, 35, 81, 173, 357, ...
- Find Nth term of the series 5, 13, 25, 41, 61...
- Find Nth term of the series 4, 2, 2, 3, 6, ...

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.