# Re: factorial(100)

7 messages
Open this post in threaded view
|

## Re: factorial(100)

 Just found this:use:#codegamma(n+1)instead of: #codefactorial(n)it's not pretty but nicer then the bigint solutions I believe.On Wednesday, February 27, 2013 at 10:58:34 PM UTC+1, nbecker wrote:Total newb here, just playing around.  A bit surprised by this: julia> factorial(100) 0
Open this post in threaded view
|

## Re: factorial(100)

 https://en.wikipedia.org/wiki/Gamma_functionJust to be on the save side.On Tuesday, September 1, 2015 at 3:32:17 PM UTC+2, Vincent Grunert wrote:Just found this:use:#codegamma(n+1)instead of: #codefactorial(n)it's not pretty but nicer then the bigint solutions I believe.On Wednesday, February 27, 2013 at 10:58:34 PM UTC+1, nbecker wrote:Total newb here, just playing around.  A bit surprised by this: julia> factorial(100) 0
Open this post in threaded view
|

## Re: factorial(100)

 In reply to this post by Vincent Grunert It's not a pretty solution but it works:use:#codegamma(n+1)instead of:#codefactorial(n)https://en.wikipedia.org/wiki/Gamma_functionOn Wednesday, February 27, 2013 at 10:58:34 PM UTC+1, nbecker wrote:Total newb here, just playing around.  A bit surprised by this: julia> factorial(100) 0
Open this post in threaded view
|

## Re: factorial(100)

 In reply to this post by Vincent Grunert On Tue, Sep 1, 2015 at 9:34 AM, Vincent Grunert <[hidden email]> wrote: > https://en.wikipedia.org/wiki/Gamma_function> > Just to be on the save side. > > > On Tuesday, September 1, 2015 at 3:32:17 PM UTC+2, Vincent Grunert wrote: >> >> Just found this: >> >> use: >> >> #code >> gamma(n+1) >> >> instead of: >> >> #code >> factorial(n) >> >> it's not pretty but nicer then the bigint solutions I believe. >> This really depend on what you need. If you need all the digits, there's no way around using BigInt. If you are doing some floating point calculation, you can use gamma, although in practice I often find lgamma is what I really need. (Since factorial often appears in some expansion coefficient with pretty big numerator and denominator. Using the log version can avoid floating point overflow) >> >> >> On Wednesday, February 27, 2013 at 10:58:34 PM UTC+1, nbecker wrote: >>> >>> Total newb here, just playing around.  A bit surprised by this: >>> >>> julia> factorial(100) >>> 0 >>> >>> >>> >
Open this post in threaded view
|

## Re: factorial(100)

 On Tuesday, September 1, 2015 at 9:39:27 AM UTC-4, Yichao Yu wrote:find lgamma is what I really need. (Since factorial often appears in some expansion coefficient with pretty big numerator and denominator. Using the log version can avoid floating point overflow) If you are doing expansions, e.g. some series formula, it is usually best to compute the series coefficients by a recurrence (e.g. compute the next coefficient as the previous coefficient multiplied by some factor), which is vastly more efficient than calling things like gamma or lgamma for each term, and typically this avoids overflow as well.