Feature suggestion -- return if true
davea at ieee.org
Mon Apr 18 04:04:47 CEST 2011
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
More interestingly, There is a gamma function defined for lots of real
and complex numbers, which for all non-negative integers matches the
gamma(n) = (n-1)!
The gamma function has the same value (1) for one and two, so to be
consistent, factorial should have that value for both zero and one.
More information about the Python-list