Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ! Вариант 3/93 в Шелесте
- program hello
- implicit none
- integer :: n
- real(8) :: fact
- do while (.true.)
- write (*,'(1x,a$)') 'Enter n:'
- read (*,*) n
- if (n >= 20 .or. n <0 ) then
- write (*,*) 'Incorrect enter!'
- cycle
- else
- exit
- end if
- end do
- !write (*,*) 'Factorial n:', fact(n)
- write (*,'(1x,a f20.5)') 'Factorial n:', fact(n)
- end program
- real(8) function fact(r)
- real(8), parameter :: pi = 3.141592653589793, e = 2.718281828459045
- real(8):: ratio(5)
- real :: multi_1, multi_2
- integer :: r,i
- ratio = [1.0, (1.0/12.0), (1.0/288.0), (-139.0/51480.0), (-571.0/2488320.0)]
- !
- fact = 0.000000
- if (r == 0) then
- fact = 1.00000000
- else
- do i = 1, size(ratio)
- fact = fact + ratio(i)/(r**(i-1))
- end do
- fact = fact*sqrt(2*pi*r)*( (r/e)**r )
- end if
- !multi_2 = ratio_1 + (ratio_2/r) + (ratio_3/(r**2)) + (ratio_4/(r**3)) + (ratio_5/(r**4))
- !fact = multi_1*multi_2
- end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement