Given a number **N**, the task is to find the **Nth** term in series **2, 3, 10, 15, 26….**

**Example:**

Input:N = 2Output:3 2nd term = (2*2)-1 = 3Input:N = 5Output:26 5th term = (5*5)+1 = 26

**Approach:**

- Nth number of the series is obtained by
- Squaring the number itself.
- If the number is odd, add 1 to the squared number. And, subtract 1 if the number is even

- Since the starting number of the series is 2
1st term = 2

2nd term = (2 * 2) – 1 = 3

3rd term = (3 * 3) + 1 = 10

4th term = (4 * 4) – 1 = 15

5th term = (5 * 5) + 1 = 26

and so on…. - In general, Nth number is obtained by formula:

Below is the implementation of the above approach:

## C++

`// C++ program to find Nth term ` `// of the series 2, 3, 10, 15, 26.... ` ` ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to find Nth term ` `int` `nthTerm(` `int` `N) ` `{ ` ` ` `int` `nth = 0; ` ` ` ` ` `// Nth term ` ` ` `if` `(N % 2 == 1) ` ` ` `nth = (N * N) + 1; ` ` ` `else` ` ` `nth = (N * N) - 1; ` ` ` ` ` `return` `nth; ` `} ` ` ` `// Driver Method ` `int` `main() ` `{ ` ` ` `int` `N = 5; ` ` ` ` ` `cout << nthTerm(N) << endl; ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to find Nth term ` `// of the series 2, 3, 10, 15, 26.... ` `class` `GFG ` `{ ` ` ` `// Function to find Nth term ` `static` `int` `nthTerm(` `int` `N) ` `{ ` ` ` `int` `nth = ` `0` `; ` ` ` ` ` `// Nth term ` ` ` `if` `(N % ` `2` `== ` `1` `) ` ` ` `nth = (N * N) + ` `1` `; ` ` ` `else` ` ` `nth = (N * N) - ` `1` `; ` ` ` ` ` `return` `nth; ` `} ` ` ` `// Driver code ` `public` `static` `void` `main(String[] args) ` `{ ` ` ` `int` `N = ` `5` `; ` ` ` ` ` `System.out.print(nthTerm(N) +` `"\n"` `); ` ` ` `} ` `} ` ` ` `// This code is contributed by Rajput-Ji ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 program to find Nth term ` `# of the series 2, 3, 10, 15, 26.... ` ` ` `# Function to find Nth term ` `def` `nthTerm(N) : ` ` ` `nth ` `=` `0` `; ` ` ` ` ` `# Nth term ` ` ` `if` `(N ` `%` `2` `=` `=` `1` `) : ` ` ` `nth ` `=` `(N ` `*` `N) ` `+` `1` `; ` ` ` `else` `: ` ` ` `nth ` `=` `(N ` `*` `N) ` `-` `1` `; ` ` ` ` ` `return` `nth; ` ` ` `# Driver Method ` `if` `__name__ ` `=` `=` `"__main__"` `: ` ` ` `N ` `=` `5` `; ` ` ` `print` `(nthTerm(N)) ; ` ` ` `# This code is contributed by AnkitRai01 ` |

*chevron_right*

*filter_none*

## C#

`// C# program to find Nth term ` `// of the series 2, 3, 10, 15, 26.... ` `using` `System; ` ` ` `class` `GFG ` `{ ` ` ` `// Function to find Nth term ` `static` `int` `nthTerm(` `int` `N) ` `{ ` ` ` `int` `nth = 0; ` ` ` ` ` `// Nth term ` ` ` `if` `(N % 2 == 1) ` ` ` `nth = (N * N) + 1; ` ` ` `else` ` ` `nth = (N * N) - 1; ` ` ` ` ` `return` `nth; ` `} ` ` ` `// Driver code ` `public` `static` `void` `Main(String[] args) ` `{ ` ` ` `int` `N = 5; ` ` ` ` ` `Console.Write(nthTerm(N) +` `"\n"` `); ` `} ` `} ` ` ` `// This code is contributed by PrinciRaj1992 ` |

*chevron_right*

*filter_none*

**Output:**

26

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## 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 Nth term of the series 1, 8, 54, 384...
- Find Nth term of the series 1, 1, 2, 6, 24...
- Find Nth term of the series 4, 2, 2, 3, 6, ...
- Find the Nth term in series 12, 35, 81, 173, 357, ...
- Find Nth term of series 1, 4, 15, 72, 420...
- Find Nth term of the series 3, 14, 39, 84...
- Find Nth term of the series 5, 13, 25, 41, 61...
- Find Nth term of the series 0, 2, 4, 8, 12, 18...
- Find the nth term of the series 0, 8, 64, 216, 512, . . .
- Find the Nth term of the series 2 + 6 + 13 + 23 + . . .
- Find Nth term of the series 0, 6, 0, 12, 0, 90...
- Find n-th term in the series 7, 15, 32, ...
- Find n-th term in the series 9, 33, 73,129 ...
- Find nth term of the series 5 2 13 41
- 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 Nth term of the series 1, 5, 32, 288 ...
- Find Nth term of the series 1, 6, 18, 40, 75, ....

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.