# Find Nth term of the series 5, 13, 25, 41, 61…

Given a number N. The task is to write a program to find the Nth term in the below series:

5, 13, 25, 41, 61...

**Examples:**

Input :3Output :25 For N = 3 Nth term = 3*3 + (3+1)*(3+1) = 25Input :5Output :61

On observing carefully, the Nth term of the given series can be generalised as:

Nth term = N^{2}+ (N+1)^{2}

Below is the implementation of the above approach:

## C++

`// CPP program to find N-th term of the series: ` `// 5, 13, 25, 41, 61... ` `#include <iostream> ` `using` `namespace` `std; ` ` ` `// calculate Nth term of series ` `int` `nthTerm(` `int` `N) ` `{ ` ` ` `return` `N * N + (N + 1) * (N + 1); ` `} ` ` ` `// Driver Function ` `int` `main() ` `{ ` ` ` `int` `N = 3; ` ` ` ` ` `cout << nthTerm(N); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to calculate Nth term of ` `// the series: 5, 13, 25, 41, 61... ` ` ` `import` `java.io.*; ` ` ` `class` `Nth { ` ` ` `public` `static` `int` `nthTerm(` `int` `N) ` ` ` `{ ` ` ` `// By using above formula ` ` ` `return` `N * N + (N + ` `1` `) * (N + ` `1` `); ` ` ` `} ` ` ` ` ` `public` `static` `void` `main(String[] args) ` ` ` `{ ` ` ` `int` `N = ` `3` `; ` `// Nth term is 25 ` ` ` ` ` `// call and print Nth term ` ` ` `System.out.println(nthTerm(N)); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

## Python 3

`# Python 3 program to find ` `# N-th term of the series: ` `# 5, 13, 25, 41, 61... ` ` ` `# Function to calculate ` `# Nth term of series ` `def` `nthTerm(N) : ` ` ` `return` `N ` `*` `N ` `+` `(N ` `+` `1` `) ` `*` `(N ` `+` `1` `) ` ` ` `# Driver Code ` `if` `__name__ ` `=` `=` `"__main__"` `: ` ` ` ` ` `N ` `=` `3` ` ` ` ` `# function calling ` ` ` `print` `(nthTerm(N)) ` ` ` `# This code is contributed ` `# by ANKITRAI1 ` |

*chevron_right*

*filter_none*

## C#

`// C# program to calculate Nth term of ` `// the series: 5, 13, 25, 41, 61... ` `using` `System; ` ` ` `class` `GFG ` `{ ` `public` `static` `int` `nthTerm(` `int` `N) ` `{ ` ` ` `// By using above formula ` ` ` `return` `N * N + (N + 1) * (N + 1); ` `} ` ` ` `// Driver Code ` `public` `static` `void` `Main() ` `{ ` ` ` `int` `N = 3; ` `// Nth term is 25 ` ` ` ` ` `// call and print Nth term ` ` ` `Console.Write(nthTerm(N)); ` `} ` `} ` ` ` `// This code is contributed ` `// by ChitraNayal ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP program to find N-th ` `// term of the series: ` `// 5, 13, 25, 41, 61... ` ` ` `// calculate Nth term of series ` `function` `nthTerm(` `$N` `) ` `{ ` ` ` `return` `$N` `* ` `$N` `+ (` `$N` `+ 1) * ` ` ` `(` `$N` `+ 1); ` `} ` ` ` `// Driver Code ` `$N` `= 3; ` ` ` `echo` `nthTerm(` `$N` `); ` ` ` `// This code is contributed ` `// by ChitraNayal ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

25

**Time Complexity:** O(1)

## Recommended Posts:

- Find the Nth term of the series where each term f[i] = f[i - 1] - f[i - 2]
- Find the nth term of the series 0, 8, 64, 216, 512, . . .
- Find n-th term in series 1 2 2 3 3 3 4 4 4 4....
- Find n-th term of series 1, 3, 6, 10, 15, 21...
- Find n-th term of series 3, 9, 21, 41, 71...
- Find the nth term of the given series
- Find n-th term in the series 7, 15, 32, ...
- Find the Nth term of the series 2 + 6 + 13 + 23 + . . .
- Find n-th term of series 1, 4, 27, 16, 125, 36, 343 .......
- Find nth term of the series 5 2 13 41
- Find n-th term in the series 9, 33, 73,129 ...
- Find Nth term of the series 0, 6, 0, 12, 0, 90...
- Find Nth term of the series 1, 6, 18, 40, 75, ....
- Find Nth term of the series 1, 5, 32, 288 ...
- Find the Nth term of the series 14, 28, 20, 40,.....

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.