Feature suggestion -- return if true
rosuav at gmail.com
Mon Apr 18 04:10:32 CEST 2011
On Mon, Apr 18, 2011 at 12:04 PM, Dave Angel <davea at ieee.org> wrote:
> On 01/-10/-28163 02:59 PM, Chris Angelico wrote:
>> 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)? :)
More information about the Python-list