# Find Nth term of the series 0, 6, 0, 12, 0, 90…

Given a number N. The task is to write a program to find the Nth term in the below series:

0, 6, 0, 12, 0, 90…

**Examples:**

Input :N = 4Output :12 For N = 4 Nth term = abs( 4 * ((4-1) * (4-3) * (4-5)) ); = 12Input :N = 6Output :90

We can generalize the Nth term of the above series as:

Nth term = abs( N * ((N-1) * (N-3) * (N-5)) )

Below is the implementation of the above approach:

## C++

`// CPP program to find N-th term of the series ` `// 0, 6, 0, 12, 0, 90... ` ` ` `#include <iostream> ` `using` `namespace` `std; ` ` ` `// Function to return the Nth term ` `int` `nthTerm(` `int` `N) ` `{ ` ` ` `return` `abs` `(N * ((N - 1) * (N - 3) * (N - 5))); ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `int` `N = 6; ` ` ` ` ` `cout << nthTerm(N); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to find N-th term of the series ` `// 0, 6, 0, 12, 0, 90... ` ` ` `import` `java.io.*; ` `import` `java.lang.*; ` ` ` `class` `GFG { ` ` ` `// Function to calculate Nth term of ` ` ` `// the series ` ` ` `public` `static` `int` `nthTerm(` `int` `N) ` ` ` `{ ` ` ` `// By using above formula ` ` ` `return` `Math.abs(N * ((N - ` `1` `) * (N - ` `3` `) * (N - ` `5` `))); ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `main(String[] args) ` ` ` `{ ` ` ` `int` `N = ` `6` `; ` `// Nth term is 6 ` ` ` ` ` `System.out.println(nthTerm(N)); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 program to find N-th ` `# term of the series ` `# 0, 6, 0, 12, 0, 90... ` ` ` `# Function to return the Nth term ` `def` `nthTerm(N) : ` ` ` ` ` `return` `(` `abs` `(N ` `*` `((N ` `-` `1` `) ` `*` `(N ` `-` `3` `) ` ` ` `*` `(N ` `-` `5` `)))) ` ` ` `# Driver code ` `if` `__name__ ` `=` `=` `"__main__"` `: ` ` ` ` ` `N ` `=` `6` ` ` ` ` `# Function calling ` ` ` `print` `(nthTerm(N)) ` ` ` ` ` `# This code is contributed by ` `# ANKITRAI1 ` |

*chevron_right*

*filter_none*

## C#

`// C# program to find N-th term of the series ` `// 0, 6, 0, 12, 0, 90... ` ` ` `using` `System; ` ` ` `class` `GFG { ` ` ` `// Function to calculate Nth term of ` ` ` `// the series ` ` ` `public` `static` `int` `nthTerm(` `int` `N) ` ` ` `{ ` ` ` `// By using above formula ` ` ` `return` `Math.Abs(N * ((N - 1) * (N - 3) * (N - 5))); ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `Main() ` ` ` `{ ` ` ` `int` `N = 6; ` `// Nth term is 6 ` ` ` ` ` `Console.WriteLine(nthTerm(N)); ` ` ` `} ` `} ` `// This code is contributed by anuj_67. ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP program to find ` `// N-th term of the series ` `// 0, 6, 0, 12, 0, 90... ` ` ` `// Function to return the Nth term ` `function` `nthTerm( ` `$N` `) ` `{ ` ` ` `return` `abs` `(` `$N` `* ((` `$N` `- 1) * ` ` ` `(` `$N` `- 3) * (` `$N` `- 5))); ` `} ` ` ` `// Driver code ` `$N` `= 6; ` ` ` `echo` `nthTerm(` `$N` `); ` ` ` `// This code is contributed ` `// by inder_verma.. ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

90

**Time Complexity**: O(1)

## 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 1, 8, 54, 384...
- Find the nth term of the series 0, 8, 64, 216, 512, . . .
- Find sum of Series with n-th term as n^2 - (n-1)^2
- Find the Nth term of the series 14, 28, 20, 40,.....
- Find n-th term in the series 9, 33, 73,129 ...
- Find Nth term of series 1, 4, 15, 72, 420...
- Find Nth term of the series 1, 6, 18, 40, 75, ....
- Find Nth term of the series 1, 5, 32, 288 ...
- Find n-th term of series 1, 4, 27, 16, 125, 36, 343 .......
- Find nth term of the series 5 2 13 41
- Find n-th term of series 2, 10, 30, 68, 130 ...
- Find Nth term of the series 1, 1, 2, 6, 24...
- Find the Nth term of the series 1 + 2 + 6 + 15 + 31 + 56 + ...
- Find n-th term of series 3, 9, 21, 41, 71...

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.