On Mon, Apr 18, 2011 at 12:04 PM, Dave Angel <da...@ieee.org> wrote: > On 01/-10/-28163 02:59 PM, Chris Angelico wrote: >> >> <snip> >> >> Sure. In my (somewhat contrived) example of factorials, that's going >> to be true (apart from 0! = 0); and if the function returns a string >> or other object rather than an integer, same thing. If there's the > > Just to be pedantic, by any reasonable definition, 0! == one, not zero. > > One reference: http://en.wikipedia.org/wiki/Factorial > 3rd sentence.
Hm! I never thought to check the definition... I just coded it up quickly, and didn't even consider the possibility of a zero return until the cache's loophole was challenged. Guess with a more correct definition of factorial, it's even safer in the cache. Question: How many factorial functions are implemented because a program needs to know what n! is, and how many are implemented to demonstrate recursion (or to demonstrate the difference between iteration and recursion)? :) ChrisA -- http://mail.python.org/mailman/listinfo/python-list