@(n,m)sum(sum(diff((perms(1:n))')>0)==m) ans(7,4)
Standard input is empty
ans = @(n, m) sum (sum (diff ((perms (1:n))') > 0) == m) ans = 1191
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!