# ***************************************************************** # *********************** FUNCTION FACTOR************************** # ***************************************************************** # # computes the factorial function for integers. # and error analysis for the physical sciences", philip r. # bevington, 1969, mCgraw hill (ny:ny) # # 27-Jan-1993 R. Williamson Converted to SPP # double procedure factor(n) double sum, fi, fact int i,n begin fact=1.0 if (n-1 > 0) { if (n-10 <= 0) { # n less than 11 do i=2,n { fi=i fact=fact*fi } # n greater than 10 } else { sum=0.0 do i = 11, n { fi=i sum=sum+dlog(fi) } fact=3628800.0d00*dexp(sum) } } return (fact) end