Created
January 13, 2018 15:52
-
-
Save ApolloZhu/64d2023a2e0baec0df70d3fb3ff3ecb6 to your computer and use it in GitHub Desktop.
codegolf.stackexchange.com/questions/96747/compute-the-eulerian-number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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