Skip to content

Instantly share code, notes, and snippets.

@komasaru
Last active November 13, 2018 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save komasaru/d62c2ac0115b6cd43ad7365c74d2d4c9 to your computer and use it in GitHub Desktop.
Save komasaru/d62c2ac0115b6cd43ad7365c74d2d4c9 to your computer and use it in GitHub Desktop.
Fortran 95 source code to compute the G.C.D.
!****************************************************
! 最大公約数計算
!
! date name version
! 2018.08.20 mk-mode.com 1.00 新規作成
!
! Copyright(C) 2018 mk-mode.com All Rights Reserved.
!****************************************************
!
program gcd_main
implicit none
write (*,*) gcd(144, 300)
stop
contains
! 最大公約数計算
!
! :param integer a
! :param integer b
! :return integer gcc
integer function gcd(a, b)
implicit none
integer, intent(IN) :: a, b
integer :: l, m, n
m = a
n = b
do
l = mod(m, n)
if (l == 0) exit
m = n
n = l
end do
gcd = n
return
end function gcd
end program gcd_main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment