pub fn gamma(x: u64) -> u64Expand description
§gamma(x)
Extended Factorial Function
Γ(n) is a way to extend the factorial function to all complex numbers
except the negative integers and zero.
For any positive integer, the Gamma function is defined as:
Γ(n)=(n−1)!
For example, the gamma of 3 (denoted as Γ(3)) is:
Γ(3)=(3−1)! = 2!=2×1=2
By definition, the Gamma function of 0 returns an error because 0 − 1 = − 1,
which is not accepted in the factorial function.
§Examples
use mathlab::math::gamma;
assert_eq!(gamma(1), 1);
assert_eq!(gamma(2), 1);
assert_eq!(gamma(3), 2);
assert_eq!(gamma(4), 6);
assert_eq!(gamma(4) as u8, 6);
assert_eq!(gamma(4) as i32, 6);
assert_eq!(gamma(4) as f64, 6.0);
assert_eq!(gamma(17), 20922789888000);
assert_eq!(gamma(19), 6402373705728000);End Fun Doc