memoize factorial example (was Re: decorators ?)

Tim Peters tim.peters at
Wed Dec 8 03:51:24 CET 2004

[Daniel 'Dang' Griffith]
>> But the factorial example on the wiki has a defect.  It incorrectly
>> calculates factorial(0) as 0, when it should be 1.

[Terry Reedy]
> 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, since you're talking about "the rabbit problem", are you sure
you're talking about the factorial example?  It sounds like you're
talking about the Fibonacci example.  I agree with Daniel about the
factorial function:  there's no disagreement about 0!=1, 1!=1, 2!=2,
3!=6, 4!=24, ..., that I've ever seen.  The first two terms in a
Fibonacci sequence are indeed arbitrary, though.

More information about the Python-list mailing list