Duncan Smith buzzard at urubu.freeserve.co.uk
Sat Jun 7 15:43:30 CEST 2003

"Rogue9" <rogue9 at ntlworld.com> wrote in message news:3ee1e6f1 at shknews01...
> Pardon me but could anyone enlighten me if python2.2 has a math function
> to call to do factorials of integers?If not then is there a code snippet
> for doing such a thing available?I tried to write some code for this
> myself but with little success.
> Thanks
> Lol

I tend to use gmpy for factorials / combinations and such-like.  But you
could use something like...

>>> def fac(n):
...  if n == 0:
...   return 1
...  else:
...   return n * fac(n-1)
>>> fac(20)


More information about the Python-list mailing list