Is there a reason you defined it as n * math.gamma(n), instead of math.gamma(n+1)?
Damian (he/him) On Thu, Sep 16, 2021 at 2:35 PM Jonatan <[email protected]> wrote: > 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 -- [email protected] > To unsubscribe send an email to [email protected] > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/[email protected]/message/HID2JPHO56Y2ZZ3MJGEGRDGPMJJLF5T3/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/SNVF3TH256XAF4UCXH3LR4T76X2YPVND/ Code of Conduct: http://python.org/psf/codeofconduct/
