Calculating factorial
Marcin 'Qrczak' Kowalczyk
qrczak at knm.org.pl
Wed Dec 6 16:18:55 EST 2000
Wed, 06 Dec 2000 16:11:11 GMT, Tim Hochberg <tim.hochberg at ieee.org> pisze:
> def factorial(n):
> result = 1L
> while n:
> result *= n
> n -= 1
> return result
>
> It's not any faster than the other choices, but it has the dubious,
> theoretical distinction of using less memory than all but the xrange version
OTOH counting upwards lets it work on smaller numbers on average.
--
__("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
\__/
^^ SYGNATURA ZASTĘPCZA
QRCZAK
More information about the Python-list
mailing list