Skip to content

Commit c264d27

Browse files
authored
add integer method
1 parent c4dd7f5 commit c264d27

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/gamma.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,11 @@ function _gamma(x::Float64)
4949
q = evalpoly(x, Q)
5050
return z * p / q
5151
end
52+
53+
54+
function gamma(n::Integer)
55+
n < 0 && throw(DomainError(n, "`n` must not be negative."))
56+
n == 0 && return Inf*float(n)
57+
n > 20 && return gamma(float(n))
58+
@inbounds return Float64(factorial(n-1))
59+
end

0 commit comments

Comments
 (0)