Last active
November 13, 2018 11:52
-
-
Save komasaru/d62c2ac0115b6cd43ad7365c74d2d4c9 to your computer and use it in GitHub Desktop.
Fortran 95 source code to compute the G.C.D.
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 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