[issue8692] Use divide-and-conquer for faster factorials
Daniel Stutzbach
report at bugs.python.org
Fri May 14 05:56:00 CEST 2010
Daniel Stutzbach <daniel at stutzbachenterprises.com> added the comment:
Attached is a patch to improve the unit tests for the factorial function.
To compute the check value, it keeps a running total instead of recomputing the factorial from scratch inside the loop. It checks up to range(999) and is quite fast. The previous code checked range(10).
It also adds the following checks:
* 0! == 1
* (sys.maxsize+1)! => OverflowError
* 10e100 => OverflowError
----------
Added file: http://bugs.python.org/file17326/factorial-test.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8692>
_______________________________________
More information about the Python-bugs-list
mailing list