Skip to content

Commit

Permalink
add integer method
Browse files Browse the repository at this point in the history
  • Loading branch information
oscardssmith authored Oct 25, 2022
1 parent c4dd7f5 commit c264d27
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/gamma.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,11 @@ function _gamma(x::Float64)
q = evalpoly(x, Q)
return z * p / q
end


function gamma(n::Integer)
n < 0 && throw(DomainError(n, "`n` must not be negative."))
n == 0 && return Inf*float(n)
n > 20 && return gamma(float(n))
@inbounds return Float64(factorial(n-1))
end

0 comments on commit c264d27

Please sign in to comment.