The Elk Code
 
Loading...
Searching...
No Matches
factn.f90
Go to the documentation of this file.
1
2! Copyright (C) 2022 J. K. Dewhurst, S. Sharma and E. K. U. Gross.
3! This file is distributed under the terms of the GNU General Public License.
4! See the file COPYING for license details.
5
6elemental real(8) function factn(n)
7implicit none
8! arguments
9integer, intent(in) :: n
10! local variables
11integer i
12real(8), parameter :: f(24)=[ &
13 1.d0, 2.d0, &
14 6.d0, 24.d0, &
15 120.d0, 720.d0, &
16 5040.d0, 40320.d0, &
17 362880.d0, 3628800.d0, &
18 39916800.d0, 479001600.d0, &
19 6227020800.d0, 87178291200.d0, &
20 1307674368000.d0, 20922789888000.d0, &
21 355687428096000.d0, 6402373705728000.d0, &
22 121645100408832000.d0, 2432902008176640000.d0, &
23 51090942171709440000.d0, 1124000727777607680000.d0, &
24 25852016738884976640000.d0, 620448401733239439360000.d0]
25if (n <= 1) then
26 factn=1.d0
27else if (n <= 24) then
28 factn=f(n)
29else
30 factn=f(24)
31 do i=25,n
32 factn=factn*dble(i)
33 end do
34end if
35end function
36
elemental real(8) function factn(n)
Definition factn.f90:7