Py-Fun <[EMAIL PROTECTED]> wrote: > I'm stuck trying to write a function that generates a factorial of a > number using iteration and not recursion. Any simple ideas would be > appreciated.
Here is the math geek answer ;-) import math def factorial(i): n = i + 1 return math.exp(-n)*(n**(n-0.5))*math.sqrt(2*math.pi)*(1. + 1./12/n + 1./288/n**2 - 139./51840/n**3) Works for non integer factorials also... See here for background http://mathworld.wolfram.com/StirlingsSeries.html -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list