Created
April 4, 2013 05:28
-
-
Save Zhangerr/5308045 to your computer and use it in GitHub Desktop.
factorial functional style?
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
>>> g = lambda x: reduce(lambda y,z:y*z,range(x,0,-1)) | |
>>> g(2) | |
2 | |
>>> g(3) | |
6 | |
>>> g(4) | |
24 | |
>>> g(5) | |
120 | |
>>> g(6) | |
720 | |
>>> g(7) | |
5040 | |
>>> g(10) | |
3628800 | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment