Skip to content

Instantly share code, notes, and snippets.

@Zhangerr
Created April 4, 2013 05:28
Show Gist options
  • Save Zhangerr/5308045 to your computer and use it in GitHub Desktop.
Save Zhangerr/5308045 to your computer and use it in GitHub Desktop.
factorial functional style?
>>> 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