Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Stirling Approx to N! for large Number?

by tall_man (Parson)
on Mar 25, 2005 at 15:46 UTC ( #442358=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub factorial_gosper {
      # sqrt(2*n*PI + 1/3)*n**n/exp(n)
      my $n = shift;
      return exp($n*log($n) - $n + 0.5*log(2*$n*PI + 1.0/3.0));
    }
    
  2. or download this
    #!/usr/bin/perl -w
    use strict;
    ...
      return exp($n*log($n) - $n + 0.5*log(2*$n*PI + 1.0/3.0));
    }
                                                                          
    +                     
    
  3. or download this
    PURE     : 40320
    STIRLING : 417351.253768542
    REAL     : 39902.3954526567
    GOSPER   : 40034.4823215513
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://442358]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2018-11-18 11:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My code is most likely broken because:
















    Results (205 votes). Check out past polls.

    Notices?