Program to find Nth term of series 9, 23, 45, 75, 113…

Given a number N, the task is to find the Nth term in the given series:

```9, 23, 45, 75, 113, 159......
```

Examples:

```Input: 4
Output: 113
Explanation:
For N = 4
Nth term = ( 2 * N + 3 )*( 2 * N + 3 ) - 2 * N
= ( 2 * 4 + 3 )*( 2 * 4 + 3 ) - 2 * 4
= 113

Input: 10
Output: 509
```

Recommended: Please try your approach on {IDE} first, before moving on to the solution.

Approach:
The Nth term of the given series can be generalised as:

```Nth term of the series : ( 2 * N + 3 )*( 2 * N + 3 ) - 2 * N
```

Below is the implementation of the above problem:

Program:

 `// CPP program to find N-th term of the series: ` `// 9, 23, 45, 75, 113... ` ` `  `#include ` `using` `namespace` `std; ` ` `  `// calculate Nth term of series ` `int` `nthTerm(``int` `N) ` `{ ` `    ``return` `(2 * N + 3) * (2 * N + 3) - 2 * N; ` `} ` ` `  `// Driver Function ` `int` `main() ` `{ ` ` `  `    ``// Get the value of N ` `    ``int` `N = 4; ` ` `  `    ``// Find the Nth term ` `    ``// and print it ` `    ``cout << nthTerm(N); ` ` `  `    ``return` `0; ` `} `

 `// Java program to find  ` `// N-th term of the series:  ` `// 9, 23, 45, 75, 113...  ` ` `  `class` `GFG  ` `{ ` ` `  `// calculate Nth term of series  ` `static` `int` `nthTerm(``int` `N)  ` `{  ` `    ``return` `(``2` `* N + ``3``) *  ` `           ``(``2` `* N + ``3``) - ``2` `* N;  ` `}  ` ` `  `// Driver code ` `public` `static` `void` `main(String[] args) ` `{ ` `     `  `    ``// Get the value of N  ` `    ``int` `N = ``4``;  ` `     `  `    ``// Find the Nth term  ` `    ``// and print it  ` `    ``System.out.println(nthTerm(N)); ` `} ` `} ` ` `  `// This code is contributed by Bilal `

 `# Python program to find  ` `# N-th term of the series:  ` `# 9, 23, 45, 75, 113...  ` `def` `nthTerm(N):  ` `     `  `    ``# calculate Nth term of series ` `    ``return` `((``2` `*` `N ``+` `3``) ``*`  `            ``(``2` `*` `N ``+` `3``) ``-` `2` `*` `N); ` ` `  `# Driver Code  ` ` `  `# Get the value of N  ` `n ``=` `4` ` `  `# Find the Nth term  ` `# and print it  ` `print``(nthTerm(n))  ` ` `  `# This code is contributed by Bilal `

 `// C# program to find  ` `// N-th term of the series:  ` `// 9, 23, 45, 75, 113...  ` `using` `System; ` ` `  `class` `GFG  ` `{ ` ` `  `// calculate Nth term of series  ` `static` `int` `nthTerm(``int` `N)  ` `{  ` `    ``return` `(2 * N + 3) *  ` `           ``(2 * N + 3) - 2 * N;  ` `}  ` ` `  `// Driver code ` `public` `static` `void` `Main() ` `{ ` `     `  `    ``// Get the value of N  ` `    ``int` `N = 4;  ` `     `  `    ``// Find the Nth term  ` `    ``// and print it  ` `    ``Console.WriteLine(nthTerm(N)); ` `} ` `} ` ` `  `// This code is contributed ` `// by Akanksha Rai(Abby_akku) `

 ` `

Output:
```113
```

Time Complexity: O(1)

Rated as one of the most sought after skills in the industry, own the basics of coding with our C++ STL Course and master the very concepts by intense problem-solving.

Check out this Author's contributed articles.

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.

Improved By : bilal-hungund, Akanksha_Rai, R_Raj

Article Tags :
Practice Tags :