Skip to content

Instantly share code, notes, and snippets.

@komasaru
Last active June 23, 2022 10:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save komasaru/1034956cc26d0ef7549b0523df183518 to your computer and use it in GitHub Desktop.
Save komasaru/1034956cc26d0ef7549b0523df183518 to your computer and use it in GitHub Desktop.
Fortran 95 source code to compute the factorial.
!****************************************************
! 階乗計算
!
! 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