The Eulerian number A(n, m)
is the number of permutations of [1, 2, ..., n]
in which exactly m
elements are greater than the previous element. These are also called rises. For example, if n = 3
, there are 3! = 6 permutations of [1, 2, 3]
1 2 3
< < 2 elements are greater than the previous
1 3 2
< > 1 ...
2 1 3
> < 1 ...
2 3 1
< > 1 ...
3 1 2
> < 1 ...
3 2 1
> > 0 ...
So the outputs for A(3, m)
for m
in [0, 1, 2, 3]
will be
A(3, 0) = 1
A(3, 1) = 4
A(3, 2) = 1
A(3, 3) = 0
Also, this is the OEIS sequence A173018.
Rules
- This is code-golf so the shortest code wins.
- The input
n
will be a nonnegative integer andm
will be a integer in the range[0, 1, ..., n]
.
Test Cases
n m A(n, m)
0 0 1
1 0 1
1 1 0
2 0 1
2 1 1
2 2 0
3 0 1
3 1 4
3 2 1
3 3 0
4 0 1
4 1 11
4 2 11
4 3 1
4 4 0
5 1 26
7 4 1191
9 5 88234
10 5 1310354
10 7 47840
10 10 0
12 2 478271
15 6 311387598411
17 1 131054
20 16 1026509354985
42 42 0
n, m
? \$\endgroup\$n = 10
. \$\endgroup\$m
if desired, but I only require that it be valid for 0 <= m <= n with 0 <= n. \$\endgroup\$