Skip to content
Related Articles
Find the Nth term of the series 14, 28, 20, 40,…..
• Difficulty Level : Medium
• Last Updated : 12 Apr, 2021

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 = 5
Output : 32

Input : N = 6
Output : 64```

Approach:

1. Initialize first number with 14.
2. 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 ``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;``}`

## 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`

## 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`

## 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`

## PHP

 ``

## Javascript

 ``
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.  To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

In case you wish to attend live classes with industry experts, please refer DSA Live Classes

My Personal Notes arrow_drop_up
{"ft_lang_label":"__label__en","ft_lang_prob":0.71254665,"math_prob":0.932425,"size":4167,"snap":"2021-21-2021-25","text_gpt3_token_len":1441,"char_repetition_ratio":0.15589719,"word_repetition_ratio":0.43655914,"special_character_ratio":0.3825294,"punctuation_ratio":0.15766263,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9992958,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-06-20T10:36:11Z\",\"WARC-Record-ID\":\"<urn:uuid:2235525d-d1af-48e5-950a-6c22ad2d39a7>\",\"Content-Length\":\"139947\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:ef19ab82-70d3-47ed-a4d0-d5bc4ec0227e>\",\"WARC-Concurrent-To\":\"<urn:uuid:450778c2-1f9d-4aa8-9ee3-058d4505b012>\",\"WARC-IP-Address\":\"23.217.129.72\",\"WARC-Target-URI\":\"https://www.geeksforgeeks.org/find-the-nth-term-of-the-series-14-28-20-40/?ref=rp\",\"WARC-Payload-Digest\":\"sha1:6OSZFLYE7BWNSFCZE676HGJSTLP2Y3LV\",\"WARC-Block-Digest\":\"sha1:UVMUPM7UFD7PYGMLVQC7SPW55SCGBAKY\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-25/CC-MAIN-2021-25_segments_1623487660269.75_warc_CC-MAIN-20210620084505-20210620114505-00337.warc.gz\"}"}