Iteration for Factorials

Steven Bethard steven.bethard at gmail.com
Fri Oct 26 21:47:08 EDT 2007


Nicko wrote:
> If you don't like the rounding errors you could try:
> 
>     def fact(n):
>         d = {"p":1L}
>         def f(i): d["p"] *= i
>         map(f, range(1,n+1))
>         return d["p"]
> 
> It is left as an exercise to the reader as to why this code will not
> work on Py3K

Serves you right for abusing map().  ;-)

STeVe



More information about the Python-list mailing list