Skip to content

Instantly share code, notes, and snippets.

@ApolloZhu
Created January 13, 2018 15:52
Show Gist options
  • Save ApolloZhu/64d2023a2e0baec0df70d3fb3ff3ecb6 to your computer and use it in GitHub Desktop.
Save ApolloZhu/64d2023a2e0baec0df70d3fb3ff3ecb6 to your computer and use it in GitHub Desktop.
codegolf.stackexchange.com/questions/96747/compute-the-eulerian-number
func A(_ n:Int,_ m:Int)->Int{return m<1 ? 1 : n>m ? (n-m)*A(n-1,m-1)+(m+1)*A(n-1,m) : 0}
print("n\tm\tA(n,m)")
_ = zip([0,1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,7,9,10,10,10,12,15,17,20,42],[0,0,1,0,1,2,0,1,2,3,0,1,2,3,4,1,4,5,5,7,10,2,6,1,16,42]).map {
print("\($0)\t\($1)\t\(A($0,$1))")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment