Given a number n, the task is to find the n-th term in series 1, 6, 18, 40, 75, …

**Example:**

Input: N = 2 Output: 6 Explanation: 2nd term = (2^2*(2+1))/2 = 6 Input: N = 5 Output: 75 Explanation: 5th term = (5^2*(5+1))/2 = 75

**Approach:**

Nth term = (N^2*(N+1))/2

Implementation of the above approach is given below:

## C++

`// CPP code to generate ` `// 'Nth' term of this sequence ` ` ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to generate a fixed number ` `int` `nthTerm(` `int` `N) ` `{ ` ` ` `int` `nth = 0; ` ` ` ` ` `//(N^2*(N+1))/2 ` ` ` `nth = (N * N * (N + 1)) / 2; ` ` ` ` ` `return` `nth; ` `} ` ` ` `// Driver Method ` `int` `main() ` `{ ` ` ` `int` `N = 5; ` ` ` ` ` `cout << nthTerm(N) << endl; ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java code to generate ` `// 'Nth' term of this sequence ` ` ` `class` `GFG { ` ` ` ` ` `// Function to generate a fixed number ` ` ` `public` `static` `int` `nthTerm(` `int` `N) ` ` ` `{ ` ` ` `int` `nth = ` `0` `; ` ` ` ` ` `//(N^2*(N+1))/2 ` ` ` `nth = (N * N * (N + ` `1` `)) / ` `2` `; ` ` ` ` ` `return` `nth; ` ` ` `} ` ` ` ` ` `// Driver Method ` ` ` `public` `static` `void` `main(String[] args) ` ` ` `{ ` ` ` `int` `N = ` `5` `; ` ` ` ` ` `System.out.println(nthTerm(N)); ` ` ` `} ` ` ` `// This code is contributed by 29AjayKumar ` `} ` |

*chevron_right*

*filter_none*

## Python3

`# python program to find out'Nth' term of this sequence ` ` ` `# Function to generate a fixed number ` `def` `nthTerm(N): ` ` ` `nth ` `=` `0` ` ` `nth ` `=` `(N ` `*` `N ` `*` `(N ` `+` `1` `))` `/` `/` `2` ` ` `return` `nth ` ` ` `# Driver code ` `N ` `=` `5` `print` `(nthTerm(N)) ` ` ` `# This code is contributed by Shrikant13 ` |

*chevron_right*

*filter_none*

## C#

`// C# code to generate ` `// 'Nth' term of this sequence ` ` ` `using` `System; ` `public` `class` `GFG { ` ` ` ` ` `// Function to generate a fixed number ` ` ` `public` `static` `int` `nthTerm(` `int` `N) ` ` ` `{ ` ` ` `int` `nth = 0; ` ` ` ` ` `//(N^2*(N+1))/2 ` ` ` `nth = (N * N * (N + 1)) / 2; ` ` ` ` ` `return` `nth; ` ` ` `} ` ` ` ` ` `// Driver Method ` ` ` `public` `static` `void` `Main(` `string` `[] args) ` ` ` `{ ` ` ` `int` `N = 5; ` ` ` ` ` `Console.WriteLine(nthTerm(N)); ` ` ` `} ` `} ` ` ` `// This code is contributed by Shrikant13 ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP code to generate ` `// 'Nth' term of this sequence ` ` ` `// Function to generate a fixed number ` `function` `nthTerm(` `$N` `) ` `{ ` ` ` `$nth` `= 0; ` ` ` ` ` `// (N^2*(N+1))/2 ` ` ` `$nth` `= (` `$N` `* ` `$N` `* (` `$N` `+ 1)) / 2; ` ` ` ` ` `return` `$nth` `; ` `} ` ` ` `// Driver Code ` `$N` `= 5; ` ` ` `echo` `nthTerm(` `$N` `); ` ` ` `// This code is contributed ` `// by chandan_jnu ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

75

**Time Complexity:** O(1)

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...

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.