Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
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 lurking in the Monastery: (2)
As of 2018-08-15 22:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:









    Results (165 votes). Check out past polls.

    Notices?