The Elk Code
factn2.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 
6 elemental real(8) function factn2(n)
7 implicit none
8 ! arguments
9 integer, intent(in) :: n
10 ! local variables
11 integer i
12 real(8), parameter :: f(38)=[ &
13  1.d0, 2.d0, &
14  3.d0, 8.d0, &
15  15.d0, 48.d0, &
16  105.d0, 384.d0, &
17  945.d0, 3840.d0, &
18  10395.d0, 46080.d0, &
19  135135.d0, 645120.d0, &
20  2027025.d0, 10321920.d0, &
21  34459425.d0, 185794560.d0, &
22  654729075.d0, 3715891200.d0, &
23  13749310575.d0, 81749606400.d0, &
24  316234143225.d0, 1961990553600.d0, &
25  7905853580625.d0, 51011754393600.d0, &
26  213458046676875.d0, 1428329123020800.d0, &
27  6190283353629375.d0, 42849873690624000.d0, &
28  191898783962510625.d0, 1371195958099968000.d0, &
29  6332659870762850625.d0, 46620662575398912000.d0, &
30  221643095476699771875.d0, 1678343852714360832000.d0, &
31  8200794532637891559375.d0, 63777066403145711616000.d0]
32 if (n <= 1) then
33  factn2=1.d0
34 else if (n <= 38) then
35  factn2=f(n)
36 else
37  factn2=dble(n)
38  do i=1,n/2-1
39  factn2=factn2*dble(n-2*i)
40  end do
41 end if
42 end function
43 
elemental real(8) function factn2(n)
Definition: factn2.f90:7