c$Header: /weru/cvs/weps/weps.src/util/math/factln.for,v 1.2 1999-04-26 20:20:30 wagner Exp $ c real function factln i (n) c c + + + PURPOSE + + + c Computes the ln(n!) for n > 0 c c Based on: c 'NUMERICAL RECIPES - The Art of Scientific Computing', c W.H. Press, B.P. Flannery, S.A. Teukolsky, W.T. Vetterling c Cambridge University Press, 1986 c pg 159 c c + + + KEYWORDS + + + c factorial c c + + + ARGUMENT DECLARATIONS + + + integer n c c c + + + ARGUMENT DEFINITIONS + + + c n - real value for values >= 0 c c + + + LOCAL VARIABLES + + + c real gammln real a(100) c data a / 100*-1 / c c + + + END SPECIFICATIONS + + + c if (n .lt. 0) then write (*,*) 'In function factln(n): negative factorial!!' endif if (n .le. 99) then if (a(n+1) .lt. 0.0) a(n+1) = gammln(n+1.0) factln = a(n+1) else factln = gammln(n+1.0) endif return end