memoize factorial example (was Re: decorators ?)

Terry Reedy tjreedy at udel.edu
Tue Dec 7 21:24:42 EST 2004


"Daniel 'Dang' Griffith" <google0 at lazytwinacres.net> wrote in message 
news:1102458244.004fc0dc548f5536ec77f769e501ff1e at teranews...
> But the factorial example on the wiki has a defect.  It incorrectly
> calculates factorial(0) as 0, when it should be 1.

This is a matter of definition, and definitions apparently differ.  fact(0) 
== 0 is a backward projection from the definition f(1) = f(2) = 1 in 
1-based systems, which is the context for the rabbit problem in which the 
first year is year 1, not year 0.  Disagreement is not defect.

Terry J. Reedy






More information about the Python-list mailing list