# Find the nth term of the series 0, 8, 64, 216, 512, . . .

Given an integer **N**, the task is to find the **N ^{th}** term of the following series:

0, 8, 64, 216, 512, 1000, 1728, . . .

**Examples:**

Input:N = 6

Output:1000

Input:N = 5

Output:512

**Approach:**

- Given series
**0, 8, 64, 216, 512, 1000, 1728, …**can also be written as**0 * (0**^{2}), 2 * (2^{2}), 4 * (4^{2}), 6 * (6^{2}), 8 * (8^{2}), 10 * (10^{2}), … - Observe that
**0, 2, 4, 6, 10, …**is in**AP**and the**nth term**of this series can be found using the formula**term = a**where_{1}+ (n – 1) * d**a**is the_{1}**first term**,**n**is the**term position**and**d**is the**common difference**. - To get the term in the original series,
**term = term * (term**i.e.^{2})**term**.^{3} - Finally print the
**term**.

Below is the implementation of the above approach:

## C++

`// C++ implementation of the approach ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to return the nth term of the given series ` `long` `term(` `int` `n) ` `{ ` ` ` `// Common difference ` ` ` `int` `d = 2; ` ` ` ` ` `// First term ` ` ` `int` `a1 = 0; ` ` ` ` ` `// nth term ` ` ` `int` `An = a1 + (n - 1) * d; ` ` ` ` ` `// nth term of the given series ` ` ` `An = ` `pow` `(An, 3); ` ` ` `return` `An; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `int` `n = 5; ` ` ` ` ` `cout << term(n); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java implementation of the approach ` `import` `java.util.*; ` `import` `java.lang.*; ` `import` `java.io.*; ` ` ` `public` `class` `GFG { ` ` ` ` ` `// Function to return the nth term of the given series ` ` ` `static` `int` `nthTerm(` `int` `n) ` ` ` `{ ` ` ` ` ` `// Common difference and first term ` ` ` `int` `d = ` `2` `, a1 = ` `0` `; ` ` ` ` ` `// nth term ` ` ` `int` `An = a1 + (n - ` `1` `) * d; ` ` ` ` ` `// nth term of the given series ` ` ` `return` `(` `int` `)Math.pow(An, ` `3` `); ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `main(String[] args) ` ` ` `{ ` ` ` `int` `n = ` `5` `; ` ` ` `System.out.println(nthTerm(n)); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 implementation of the approach ` ` ` `# Function to return the nth term of the given series ` `def` `term(n): ` ` ` ` ` `# Common difference ` ` ` `d ` `=` `2` ` ` ` ` `# First term ` ` ` `a1 ` `=` `0` ` ` ` ` `# nth term ` ` ` `An ` `=` `a1 ` `+` `(n` `-` `1` `)` `*` `d ` ` ` ` ` `# nth term of the given series ` ` ` `An ` `=` `An` `*` `*` `3` ` ` `return` `An; ` ` ` ` ` `# Driver code ` `n ` `=` `5` `print` `(term(n)) ` |

*chevron_right*

*filter_none*

## C#

`// C# implementation of the approach ` `using` `System; ` `public` `class` `GFG { ` ` ` ` ` `// Function to return the nth term of the given series ` ` ` `static` `int` `nthTerm(` `int` `n) ` ` ` `{ ` ` ` ` ` `// Common difference and first term ` ` ` `int` `d = 2, a1 = 0; ` ` ` ` ` `// nth term ` ` ` `int` `An = a1 + (n - 1) * d; ` ` ` ` ` `// nth term of the given series ` ` ` `return` `(` `int` `)Math.Pow(An, 3); ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `Main() ` ` ` `{ ` ` ` `int` `n = 5; ` ` ` `Console. WriteLine(nthTerm(n)); ` ` ` `} ` `} ` `// This code is contributed by Mutual singh. ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP implementation of the approach ` ` ` `// Function to return the nth term of the given series ` `function` `term(` `$n` `) ` `{ ` ` ` ` ` `// Common difference ` ` ` `$d` `= 2; ` ` ` ` ` `// First term ` ` ` `$a1` `= 0; ` ` ` ` ` `// nth term ` ` ` `$An` `=` `$a1` `+(` `$n` `-1)*` `$d` `; ` ` ` ` ` `// nth term of the given series ` ` ` `return` `pow(` `$An` `, 3); ` ` ` `} ` ` ` `// Driver code ` `$n` `= 5; ` `echo` `term(` `$n` `); ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

512

## Recommended Posts:

- Find the Nth term of the series where each term f[i] = f[i - 1] - f[i - 2]
- Find Nth term of the series 0, 6, 0, 12, 0, 90...
- Find n-th term in the series 7, 15, 32, ...
- Find Nth term of the series 3, 14, 39, 84...
- Find n-th term of series 2, 10, 30, 68, 130 ...
- Find Nth term of the series 5, 13, 25, 41, 61...
- Find the Nth term of the series 1 + 2 + 6 + 15 + 31 + 56 + ...
- Find sum of Series with n-th term as n^2 - (n-1)^2
- Find n-th term of series 3, 9, 21, 41, 71...
- Find the Nth term of the series 2 + 6 + 13 + 23 + . . .
- Find nth Term of the Series 1 2 2 4 4 4 4 8 8 8 8 8 8 8 8 ...
- Find n-th term of series 1, 3, 6, 10, 15, 21...
- Find n-th term in series 1 2 2 3 3 3 4 4 4 4....
- 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.