aboutsummaryrefslogtreecommitdiff
path: root/math/bevington/factor.f
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /math/bevington/factor.f
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'math/bevington/factor.f')
-rw-r--r--math/bevington/factor.f39
1 files changed, 39 insertions, 0 deletions
diff --git a/math/bevington/factor.f b/math/bevington/factor.f
new file mode 100644
index 00000000..23b23307
--- /dev/null
+++ b/math/bevington/factor.f
@@ -0,0 +1,39 @@
+c function factor.f
+c
+c source
+c Bevington, page 32.
+c
+c purpose
+c calculates factorial function for integers
+c
+c usage
+c result = factor (n)
+c
+c description of parameters
+c n - integer argument
+c
+c subroutines and function subprograms required
+c none
+c
+ function factor (n)
+ double precision fi,sum
+11 factor=1.
+ if (n-1) 40,40,13
+13 if (n-10) 21,21,31
+c
+c n less than 11
+c
+21 do 23 i=2,n
+ fi=i
+23 factor=factor*fi
+ goto 40
+c
+c n greater than 10
+c
+31 sum=0.
+ do 34 i=11,n
+ fi=i
+34 sum=sum+dlog(fi)
+35 factor=3628800.*dexp(sum)
+40 return
+ end