Second-order Eulerian numbers
Last Updated :
28 Feb, 2023
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: 1
term = 1
Input: N = 4
Output: 8
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
Below is the implementation of above approach:
C++
#include <iostream>
#include <math.h>
using namespace std;
void findNthTerm( int n)
{
cout << pow (2, n) - 2 * n << endl;
}
int main()
{
int N = 4;
findNthTerm(N);
return 0;
}
|
Java
class GFG{
static void findNthTerm( int n)
{
System.out.println(Math.pow( 2 , n) - 2 * n);
}
public static void main(String[] args)
{
int N = 4 ;
findNthTerm(N);
}
}
|
Python3
def findNthTerm(n):
print ( pow ( 2 , n) - 2 * n);
N = 4 ;
findNthTerm(N);
|
C#
using System;
class GFG{
static void findNthTerm( int n)
{
Console.Write(Math.Pow(2, n) - 2 * n);
}
public static void Main()
{
int N = 4;
findNthTerm(N);
}
}
|
Javascript
<script>
function findNthTerm(n)
{
document.write((Math.pow(2, n)) - (2 * n));
}
N = 4;
findNthTerm(N);
</script>
|
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
Share your thoughts in the comments
Please Login to comment...