Given a series 9, 33, 73, 129… Find the n-th term of the series.

Examples:

Input : n = 4 Output : 129 Input : n = 5 Output : 201

The given series has a pattern which is visible after subtracting it from itself after one shift

S = 9 + 33 + 73 + 129 + … t_{n-1}+ t_{n}S = 9 + 33 + 73 + … t_{n-2}+ t_{n-1}+ t_{n}——————————————— 0 = 9 + (24 + 40 + 56 + ….) - t_{n}Since 24 + 40 + 56.. series in A.P with common difference of 16, we get t_{n}= 9 + [((n-1)/2)*(2*24 + (n-1-1)d)] On solving this we gett_{n}= 8n^{2}+ 1

Below is the implementation of the above approach:

## C++

`// Program to find n-th element in the ` `// series 9, 33, 73, 128.. ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Returns n-th element of the series ` `int` `series(` `int` `n) ` `{ ` ` ` `return` `(8 * n * n) + 1; ` `} ` ` ` `// driver program to test the above function ` `int` `main() ` `{ ` ` ` `int` `n = 5; ` ` ` `cout << series(n); ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Program to find n-th element in the ` `// series 9, 33, 73, 128.. ` `import` `java.io.*; ` ` ` `class` `GFG{ ` ` ` ` ` `// Returns n-th element of the series ` ` ` `static` `int` `series(` `int` `n) ` ` ` `{ ` ` ` `return` `(` `8` `* n * n) + ` `1` `; ` ` ` `} ` ` ` ` ` `// driver program to test the above ` ` ` `// function ` ` ` `public` `static` `void` `main(String args[]) ` ` ` `{ ` ` ` `int` `n = ` `5` `; ` ` ` `System.out.println(series(n)); ` ` ` `} ` `} ` ` ` `/*This code is contributed by Nikita Tiwari.*/` |

*chevron_right*

*filter_none*

## Python3

`# Python Program to find n-th element ` `# in the series 9, 33, 73, 128... ` ` ` `# Returns n-th element of the series ` `def` `series(n): ` ` ` `print` `(( ` `8` `*` `n ` `*` `*` `2` `) ` `+` `1` `) ` ` ` `# Driver Code ` `series(` `5` `) ` ` ` `# This code is contributed by Abhishek Agrawal. ` |

*chevron_right*

*filter_none*

## C#

`// C# program to find n-th element in the ` `// series 9, 33, 73, 128.. ` `using` `System; ` ` ` `class` `GFG { ` ` ` ` ` `// Returns n-th element of the series ` ` ` `static` `int` `series(` `int` `n) ` ` ` `{ ` ` ` `return` `(8 * n * n) + 1; ` ` ` `} ` ` ` ` ` `// driver function ` ` ` `public` `static` `void` `Main() ` ` ` `{ ` ` ` `int` `n = 5; ` ` ` `Console.WriteLine(series(n)); ` ` ` `} ` `} ` ` ` `/*This code is contributed by vt_m.*/` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP Program to find n-th element ` `// in the series 9, 33, 73, 128.. ` ` ` `// Returns n-th element ` `// of the series ` `function` `series(` `$n` `) ` `{ ` ` ` `return` `(8 * ` `$n` `* ` `$n` `) + 1; ` `} ` ` ` `// Driver Code ` `$n` `= 5; ` `echo` `(series(` `$n` `)); ` ` ` `// This code is contributed by Ajit. ` `?> ` |

*chevron_right*

*filter_none*

Output:

201

**Time complexity:** O(1)

This article is contributed by **Striver**. 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 write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

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:

- Nth term where K+1th term is product of Kth term with difference of max and min digit of Kth term
- Find the Nth term of the series where each term f[i] = f[i - 1] - f[i - 2]
- Find Nth term of the series where each term differs by 6 and 2 alternately
- Nth term of a sequence formed by sum of current term with product of its largest and smallest digit
- Program to find Nth term in the given Series
- Program to find the Nth term of the series 3, 7, 13, 21, 31.....
- Program to find Nth term of series 1, 3, 12, 60, 360…
- Program to find the Nth term of series -1, 2, 11, 26, 47......
- Program to find Nth term in the series 0, 0, 2, 1, 4, 2, 6, 3, 8,...
- Program to find Nth term of series 9, 23, 45, 75, 113...
- Program to find Nth term in the series 0, 2, 1, 3, 1, 5, 2, 7, 3,…
- Find Nth term of the series 5, 13, 25, 41, 61...
- Program to find the Nth term of the series 3, 20, 63, 144, 230, ……
- Program to find the Nth term of series 5, 10, 17, 26, 37, 50, 65, 82, ...
- Program to find the Nth term of series 0, 4, 14, 30, 51, 80, 114, 154, 200, ...
- Find Nth term of the series 3, 14, 39, 84...
- Program to find the Nth term of the series 0, 14, 40, 78, 124, ...
- Program to find the Nth term of the series 0, 5, 14, 27, 44, ........
- Find Nth term of the series 1, 8, 54, 384...
- Find Nth term of the series 1, 1, 2, 6, 24...