Given a number . The task is to find the **N-th** term in the following series:

14, 28, 20, 40, 32, 64…..

**Examples:**

Input :N = 5Output :32Input :N = 6Output :64

**Approach:**

- Initialize first number with 14.
- Run a loop from
**i = 2 to N**and do following steps:- For Even i, double the previous term. For example if i = 2, current term will be 2*(term when i = 1), that is 2*14 = 28.
- For Odd i, subtract 8 from the previous term.
- Exit the loop and print the final number.

Below is the implementation of the above approach:

## C++

`// CPP program to find the Nth term of ` `// the series 14, 28, 20, 40, ….. ` ` ` `#include <iostream> ` `using` `namespace` `std; ` ` ` `// Function to find the N-th term ` `int` `findNth(` `int` `N) ` `{ ` ` ` `// initializing the 1st number ` ` ` `int` `b = 14; ` ` ` ` ` `int` `i; ` ` ` ` ` `// loop from 2nd term to nth term ` ` ` `for` `(i = 2; i <= N; i++) { ` ` ` `// if i is even, double the ` ` ` `// previous number ` ` ` `if` `(i % 2 == 0) ` ` ` `b = b * 2; ` ` ` `// if i is odd, subtract 8 from ` ` ` `// previous number ` ` ` `else` ` ` `b = b - 8; ` ` ` `} ` ` ` ` ` `return` `b; ` `} ` ` ` `// Driver Code ` `int` `main() ` `{ ` ` ` `int` `N = 6; ` ` ` ` ` `cout << findNth(N); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to find the Nth term of ` `// the series 14, 28, 20, 40, ` ` ` `import` `java.io.*; ` ` ` `class` `GFG { ` ` ` ` ` `// Function to find the N-th term ` ` ` `static` `int` `findNth(` `int` `N) ` `{ ` ` ` `// initializing the 1st number ` ` ` `int` `b = ` `14` `; ` ` ` ` ` `int` `i; ` ` ` ` ` `// loop from 2nd term to nth term ` ` ` `for` `(i = ` `2` `; i <= N; i++) { ` ` ` `// if i is even, double the ` ` ` `// previous number ` ` ` `if` `(i % ` `2` `== ` `0` `) ` ` ` `b = b * ` `2` `; ` ` ` `// if i is odd, subtract 8 from ` ` ` `// previous number ` ` ` `else` ` ` `b = b - ` `8` `; ` ` ` `} ` ` ` ` ` `return` `b; ` `} ` ` ` `// Driver Code ` ` ` ` ` ` ` `public` `static` `void` `main (String[] args) { ` ` ` `int` `N = ` `6` `; ` ` ` ` ` `System.out.print(findNth(N)); ` ` ` `} ` `} ` `// This code is contributed by shs ` |

*chevron_right*

*filter_none*

## Python 3

`# Python 3 program to find the Nth term ` `# of the series 14, 28, 20, 40, ….. ` ` ` `# Function to find the N-th term ` `def` `findNth(N): ` ` ` ` ` `# initializing the 1st number ` ` ` `b ` `=` `14` ` ` ` ` `# loop from 2nd term to nth term ` ` ` `for` `i ` `in` `range` `(` `2` `, N ` `+` `1` `): ` ` ` ` ` `# if i is even, double the ` ` ` `# previous number ` ` ` `if` `(i ` `%` `2` `=` `=` `0` `): ` ` ` `b ` `=` `b ` `*` `2` ` ` ` ` `# if i is odd, subtract 8 from ` ` ` `# previous number ` ` ` `else` `: ` ` ` `b ` `=` `b ` `-` `8` ` ` ` ` `return` `b ` ` ` `# Driver Code ` `N ` `=` `6` ` ` `print` `(findNth(N)) ` ` ` `# This code is contributed ` `# by Akanksha Rai ` |

*chevron_right*

*filter_none*

## C#

`// C# program to find the Nth term of ` `// the series 14, 28, 20, 40, ` ` ` `using` `System; ` ` ` `public` `class` `GFG{ ` ` ` `// Function to find the N-th term ` `static` `int` `findNth(` `int` `N) ` `{ ` ` ` `// initializing the 1st number ` ` ` `int` `b = 14; ` ` ` ` ` `int` `i; ` ` ` ` ` `// loop from 2nd term to nth term ` ` ` `for` `(i = 2; i <= N; i++) { ` ` ` `// if i is even, double the ` ` ` `// previous number ` ` ` `if` `(i % 2 == 0) ` ` ` `b = b * 2; ` ` ` `// if i is odd, subtract 8 from ` ` ` `// previous number ` ` ` `else` ` ` `b = b - 8; ` ` ` `} ` ` ` ` ` `return` `b; ` `} ` ` ` `// Driver Code ` ` ` ` ` `static` `public` `void` `Main (){ ` ` ` `int` `N = 6; ` ` ` `Console.WriteLine(findNth(N)); ` ` ` `} ` `} ` `// This code is contributed by ajit ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP program to find the Nth term of ` `// the series 14, 28, 20, 40, ….. ` ` ` `// Function to find the N-th term ` `function` `findNth(` `$N` `) ` `{ ` ` ` `// initializing the 1st number ` ` ` `$b` `= 14; ` ` ` ` ` `// loop from 2nd term to nth term ` ` ` `for` `(` `$i` `= 2; ` `$i` `<= ` `$N` `; ` `$i` `++) ` ` ` `{ ` ` ` `// if i is even, double the ` ` ` `// previous number ` ` ` `if` `(` `$i` `% 2 == 0) ` ` ` `$b` `= ` `$b` `* 2; ` ` ` ` ` `// if i is odd, subtract 8 from ` ` ` `// previous number ` ` ` `else` ` ` `$b` `= ` `$b` `- 8; ` ` ` `} ` ` ` `return` `$b` `; ` `} ` ` ` `// Driver Code ` `$N` `= 6; ` `echo` `findNth(` `$N` `); ` ` ` `// This code is contributed by akt_mit ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

64

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.