Skip to main content
1 of 2
Giuseppe
  • 29.4k
  • 3
  • 33
  • 106

#R, 47 bytes n=scan();if(!n,1,floor(gamma(n+1)/exp(1)+.5)) Uses the same formula as Mego's answer.

Alternate method, 52 bytes using the PerMallows library

n=scan();`if`(!n,1,PerMallows::count.perms(n,n,'h')) 
Giuseppe
  • 29.4k
  • 3
  • 33
  • 106