The Wayback Machine - https://web.archive.org/web/20211223153242/https://www.geeksforgeeks.org/find-the-nth-term-of-the-series-5-13-37-109-325/
Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Find the Nth term of the series 5, 13, 37, 109, 325, . . .

  • Last Updated : 23 Dec, 2021

Given a positive integer N. The task is to find Nth term of the series 5, 13, 37, 109, 325, …..

Examples:

Attention reader! Don’t stop learning now. Get hold of all the important mathematical concepts for competitive programming with the Essential Maths for CP Course at a student-friendly price. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

Input: N = 5
Output: 325
Explanation:  From the sequence it can be seen that the 5th term is 325

Input: N = 1
Output: 5
Explanation: The 1st term of the given sequence is 5



 

Approach: The sequence formed by using the following patter. For any value N 

TN = 4 * 3N – 1 + N

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 calcNum(int N) 
{ 
  return 4 * pow(3, N - 1) + 1; 
}
  
// Driver Code
int main()
{
    int N = 5;
  
    cout << calcNum(N);
    return 0;
}
Output
325

Time Complexity: O(1)
Auxiliary Space: O(1)

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!