Issue 35637: Factorial should be able to evaluate float arguments

Issue35637

Created on 2019-01-02 11:14 by FR4NKESTI3N, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg332862 - (view) Author: Yash Aggarwal (FR4NKESTI3N) * Date: 2019-01-02 11:14
Factorial as of now accepts only integers or integral floats. 
I want to suggest extending the definition of float to accept all positive real numbers to be more consistent with general definition of factorial that uses gamma function.

What I am proposing is:
1. for integer value, the function should work as it does and return integer result.

2. for float input, both integer and non-integer valued, the returned value should be a floating point number.

3. the input domain should be extended to all real numbers except negative integers.

Such generalized function would feel more mathematically consistent.
msg332869 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2019-01-02 12:43
See related discussion in issue #33083.

Are you aware that `math.gamma` and `math.lgamma` exist? These already provide the ability to compute the "factorial" of a non-integral input.

I'd be opposed to extending math.factorial to accept non-integral floats.
msg332870 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-01-02 12:45
I concur with Mark.
History
Date User Action Args
2022-04-11 14:59:09adminsetgithub: 79818
2019-01-02 12:45:13serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg332870

resolution: rejected
stage: resolved

2019-01-02 12:43:20mark.dickinsonsetnosy: + mark.dickinson
messages: + msg332869
2019-01-02 11:14:25FR4NKESTI3Ncreate