Currently, math.factorial only supports integers and not floats, whereas the 
"mathematical" version supports both integers and floats.
I.e:
```
import math


def better_factorial(n):
    return n * math.gamma(n)

print(math.factorial(10) == better_factorial(10))
```

This ends up in `True`, as that's correct.
However, `math.factorial(math.pi)` (for example, or any float)
Ends up in `ValueError: factorial() only accepts integral values`.
unlike `better_factorial(math.pi)` which would end up in 7.188082728976031.

My proposal is to make another function for floats, or even use the same 
math.factorial function and check inside it whether the given input is an 
integer or a float object.

I would like to hear your review.
Jonathan.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/HID2JPHO56Y2ZZ3MJGEGRDGPMJJLF5T3/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to