Open In App

Second decagonal numbers

The Second decagonal numbers series can be represented as 

7, 22, 45, 76, 115, 162, 217, 280,,…..



Nth term
Given an integer N. The task is to find the N-th term of the given series.
Examples

Input: N = 1 
Output: 7




Input: N = 4 
Output: 76   

Approach: The idea is to find the general term for the Second decagonal numbers. Below is the computation of the general term for second decagonal numbers:  

1st Term = 1 * (4*1 + 3) = 7 
2nd term = 2 * (4*2 + 3) = 22 
3rd term = 3 * (4*3 + 3) = 45 
4th term = 4 * (4*4 + 3) = 76 



Nth term = n * (4 * n + 3) 
Therefore, the Nth term of the series is given as 

Below is the implementation of above approach: 

// C++ implementation to
// find N-th term in the series
 
#include <iostream>
#include <math.h>
using namespace std;
 
// Function to find N-th term
// in the series
void findNthTerm(int n)
{
    cout << n * (4 * n + 3) << endl;
}
 
// Driver Code
int main()
{
    int N = 4;
    findNthTerm(N);
 
    return 0;
}

                    
// Java program for the above approach
class GFG{
 
// Function to find N-th term
// in the series
static void findNthTerm(int n)
{
    System.out.println(n * (4 * n + 3));
}
 
// Driver code
public static void main(String[] args)
{
    int N = 4;
     
    findNthTerm(N);
}
}
 
// This code is contributed by Pratima Pandey

                    
# Python3 implementation to
# find N-th term in the series
 
# Function to find N-th term
# in the series
def findNthTerm(n):
 
    print(n * (4 * n + 3))
 
# Driver Code
N = 4;
findNthTerm(N);
 
# This code is contributed by Code_Mech

                    
// C# program for the above approach
using System;
class GFG{
 
// Function to find N-th term
// in the series
static void findNthTerm(int n)
{
    Console.WriteLine(n * (4 * n + 3));
}
 
// Driver code
public static void Main(String[] args)
{
    int N = 4;
     
    findNthTerm(N);
}
}
 
// This code is contributed by 29AjayKumar

                    
<script>
// Javascript implementation to
// find N-th term in the series
 
// Function to find N-th term
// in the series
function findNthTerm(n)
{
    document.write(n * (4 * n + 3));
}
 
// Driver Code
let N = 4;
findNthTerm(N);
 
// This code is contributed by subhammahato348.
</script>

                    

Output: 
76

 

Time Complexity: O(1)

Auxiliary Space: O(1)

Reference: OEIS


Article Tags :