Open In App

Find the Nth term of the series 3, 5, 9, 17, 33. . .

Last Updated : 16 Aug, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Given a positive integer N, the task is to find Nth term of the series-

3, 5, 9, 17, 33…till N terms

Examples:

Input: N = 4
Output: 17

Input: N = 3
Output: 9

 

Approach: 

Consider the below example:

Lets say N = 4

The 4th term of the given series is 17, i.e. : 2 ^ 4 + 1 = 16 + 1 = 17

Similarly, lets say N = 3

The 3rd term of the given series is : 2 ^ 3 + 1 = 8 + 1 = 9 (which is correct).

Therefore, we can find out the relation for Nth term of the series using above observations:

1st term = 3 = 21 + 1

2nd term = 22 + 1 = 5

3rd term = 23 + 1 = 9

4th term = 24 + 1 = 17

.

.

Therefore, Nth term can be found out using following relation: 2N + 1

Upon generalising, the relation for Nth term can be represented as:

T_{N} = 2^{N} + 1

Below is the implementation of the above approach-

C++

// C++ program to implement
// the above approach
#include <bits/stdc++.h>
using namespace std;
 
// Function to return Nth
// term of the series
int findTerm(int N)
{
    return pow(2, N) + 1;
}
 
// Driver Code
int main()
{
    int N = 6;
    cout << findTerm(N);
    return 0;
}

                    

Java

// Java program to implement
// the above approach
import java.io.*;
 
class GFG {
 
  // Function to return Nth
  // term of the series
  static int findTerm(int N)
  {
    return (int)Math.pow(2, N) + 1;
  }
 
  // Driver Code
  public static void main (String[] args)
  {
    int N = 6;
    System.out.print(findTerm(N));
  }
}
 
// This code is contributed by Shubham Singh

                    

Python3

# Python program to implement
# the above approach
 
# Function to return Nth
# term of the series
def findTerm(N):
    return (2 ** N) + 1;
 
# Driver Code
N = 6;
print(findTerm(N));
 
# This code is contributed by gfgking

                    

C#

// C# program to implement
// the above approach
using System;
class GFG
{
 
  // Function to return Nth
  // term of the series
  static int findTerm(int N)
  {
    return (int)Math.Pow(2, N) + 1;
  }
 
  // Driver Code
  public static void Main()
  {
    int N = 6;
    Console.Write(findTerm(N));
  }
}
 
// This code is contributed by Samim Hossain Mondal.

                    

Javascript

<script>
    // JavaScript program to implement
    // the above approach
 
    // Function to return Nth
    // term of the series
    const findTerm = (N) => {
        return Math.pow(2, N) + 1;
    }
 
    // Driver Code
    let N = 6;
    document.write(findTerm(N));
 
// This code is contributed by rakeshsahni
 
</script>

                    

Output
65

Time Complexity: O(logN) because it using inbuilt pow function
Auxiliary Space: O(1)



Similar Reads

Nth term where K+1th term is product of Kth term with difference of max and min digit of Kth term
Given two integers N and D, the task is to find the value of F(N) where the value of F(1) is D, where F(K) is given as: [Tex]F(K+1) = F(K) * (Max_{Digit}(F(K)) - Min_{Digit}(F(K)))[/Tex] Examples: Input: N = 3, D = 487 Output: 15584 Explanation: As F(1) = 487, F(2) = 487 * (maxDigit(487) - minDigit(487)) = 487 * 4 = 1948 F(3) = 1948 * (maxDigit(194
6 min read
Find Nth term of the series where each term differs by 6 and 2 alternately
Given a number N, the task is to find the Nth term of the series where each term differs by 6 and 2 alternately.Examples: Input: N = 6 Output: 24 Explanation: The Nth term is 0 + 6 + 2 + 6 + 2 + 6 + 2 = 24Input: N = 3 Output: 14 Explanation: The Nth term is 0 + 6 + 2 + 6 = 14 Naive Approach: The idea is to iterate from 1 with an increment of 6 and
7 min read
Find the Nth term of the series where each term f[i] = f[i - 1] - f[i - 2]
Given three integers X, Y and N, the task is to find the Nth term of the series f[i] = f[i - 1] - f[i - 2], i &gt; 1 where f[0] = X and f[1] = Y.Examples: Input: X = 2, Y = 3, N = 3 Output: -2 The series will be 2 3 1 -2 -3 -1 2 and f[3] = -2Input: X = 3, Y = 7, N = 8 Output: 4 Approach: An important observation here is that there will be atmost 6
10 min read
Nth term of a sequence formed by sum of current term with product of its largest and smallest digit
Given two numbers N and K, where K represents the starting term of the sequence. The task is to find the Nth term of a sequence formed by sum of current term with product of largest and smallest digit of current term, i.e., AN+1 = AN + max(digits of AN) * min(digits of AN) Examples: Input: K = 1, N = 5 Output: 50 Explanation: A1 = 1 A2 = A1 + minDi
6 min read
Nth term of given recurrence relation having each term equal to the product of previous K terms
Given two positive integers N and K and an array F[] consisting of K positive integers. The Nth term of the recurrence relation is given by: FN = FN - 1 * FN - 2 * FN - 3 *.......* FN - K The task is to find the Nth term of the given recurrence relation. As the Nth term can be very large, print the Nth term modulo 109 + 7. Examples: Input: N = 5, K
16 min read
First term from given Nth term of the equation F(N) = (2 * F(N - 1)) % 10^9 + 7
Given an integer N and an integer FN which denotes the Nth term of the linear equation F(N) = (2 * F(N - 1)) % M, where M is 109 + 7, the task is to find the value of F(1). Examples: Input : N = 2, FN = 6 Output:3 Explanation: If F(1) = 3, F(2) = (2 * F(1)) % M = (2 * 3) % M = 6. For F(1) = 3 the given linear equation satisfies the value of F(2). T
8 min read
Program to find Nth term of series 1, 3, 12, 60, 360…
Given a number N. The task is to write a program to find the Nth term in the below series: 1, 3, 12, 60, 360… Examples: Input: 2 Output: 3 Input: 4 Output: 60 Approach: The idea is to first find the factorial of the number (N+1), that is (N+1)!Now, the N-th term in the above series will be: N-th term = (N+1)!/2 Below is the implementation of the ab
5 min read
Program to find the Nth term of series -1, 2, 11, 26, 47......
Given a number N, the task is to find the Nth term of this series: -1, 2, 11, 26, 47, 74, ..... Examples: Input: 3 Output: 11 Explanation: when N = 3 Nth term = ( (3 * N * N) - (6 * N) + 2 ) = ( (3 * 3 * 3) - (6 * 3) + 2 ) = 11 Input: 9 Output: 191 Approach: The Nth term of the given series can be generalised as: Nth term of the series : ( (3 * N *
3 min read
Program to find Nth term in the series 0, 0, 2, 1, 4, 2, 6, 3, 8,...
Given a number N. The task is to write a program to find the N-th term in the below series: 0, 0, 2, 1, 4, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8,..... Examples: Input : N = 10 Output : 4 Input : N = 7 Output : 6 On observing carefully, you will find that the series is a mixture of 2 series: Terms at odd positions in the given series form the se
5 min read
Program to find Nth term of series 9, 23, 45, 75, 113...
Given a number N, the task is to find the Nth term in the given series: 9, 23, 45, 75, 113, 159...... Examples: Input: 4 Output: 113 Explanation: For N = 4 Nth term = ( 2 * N + 3 )*( 2 * N + 3 ) - 2 * N = ( 2 * 4 + 3 )*( 2 * 4 + 3 ) - 2 * 4 = 113 Input: 10 Output: 509 Approach: The Nth term of the given series can be generalised as: Nth term of the
4 min read
Article Tags :
Practice Tags :