Last active
June 23, 2022 10:00
-
-
Save komasaru/1034956cc26d0ef7549b0523df183518 to your computer and use it in GitHub Desktop.
Fortran 95 source code to compute the factorial.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!**************************************************** | |
! 階乗計算 | |
! | |
! date name version | |
! 2018.08.20 mk-mode.com 1.00 新規作成 | |
! | |
! Copyright(C) 2018 mk-mode.com All Rights Reserved. | |
!**************************************************** | |
! | |
program fact_main | |
implicit none | |
integer n | |
do n = 0, 20 | |
write (*,'(I3,3X,I20)') n, fact(n) | |
enddo | |
stop | |
contains | |
! 階乗計算 | |
! | |
! :param integer n | |
! :return integer fact | |
integer(kind=8) recursive function fact(n) | |
implicit none | |
integer, intent(IN) :: n | |
integer :: i | |
fact = 1 | |
do i = 1, n | |
fact = fact * i | |
enddo | |
return | |
end function fact | |
end program fact_main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment