Open In App

Second-order Eulerian numbers

Improve
Improve
Like Article
Like
Save
Share
Report

The d-order Eulerian numbers series can be represented as 
 

1, 0, 0, 2, 8, 22, 52, 114, 240, 494, 1004, …..


 

Nth term


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

Input: N = 0 
Output:
0^{th}   term = 1
Input: N = 4 
Output:
 


 


Approach: The idea is to find the general term for the Second-order Eulerian numbers. Below is the computation of the general term for second-order eulerian numbers: 
 

0th term = 20 – 2*0 = 1 
1st Term = 21 – 2*1 = 0 
2nd term = 22 – 2*2 = 0 
3rd term = 23 – 2*3 = 2 
4th term = 24 – 2*4 = 8 
5th term = 25 – 2*5 = 22 



Nth term = 2n – 2*n. 
Therefore, the Nth term of the series is given as 2^n - 2*n
 


Below is the implementation of above approach: 
 

C++

// 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 << pow(2, n) - 2 * n << endl;
}
 
// Driver Code
int main()
{
    int N = 4;
    findNthTerm(N);
 
    return 0;
}

                    

Java

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

                    

Python3

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

                    

C#

// C# implementation to find
// N-th term in the series
using System;
class GFG{
 
// Function to find N-th term
// in the series
static void findNthTerm(int n)
{
    Console.Write(Math.Pow(2, n) - 2 * n);
}
 
// Driver code
public static void Main()
{
    int N = 4;
    findNthTerm(N);
}
}
 
// This code is contributed by Code_Mech

                    

Javascript

<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((Math.pow(2, n)) - (2 * n));
}
 
// Driver Code
N = 4;
findNthTerm(N);
 
</script>

                    

Output: 
8

 

The time complexity to compute the second-order Eulerian numbers using this recurrence relation is O(n^2), where n is the maximum value of n or m. This is because we need to compute each value of A(n, m) by recursively computing A(n-1, m) and A(n-1, m-1) until we reach the base case A(0, 0) = 1.

Reference:OEIS
 



Last Updated : 28 Feb, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads