def factorial(n):
n = abs(int(n))
n = 1 if not n else n
return reduce(lambda x,y: x*y, xrange(1, n+1))
It's a waste of time when the math module already contains math.factorial, but it just shows off some of the more esoteric features of Python.
Life, Tech, Love, and Whatever Tickles My Fancy
def factorial(n):
n = abs(int(n))
n = 1 if not n else n
return reduce(lambda x,y: x*y, xrange(1, n+1))