chap04/kadai4.f90

サンプルコードのダウンロード

 1program answer
 2  implicit none
 3
 4  integer :: m, n, l, r
 5
 6  read(*, *) m, n
 7
 8  r = mod(m, n)
 9  do while(r /= 0)
10    m = n
11    n = r
12    r = mod(m, n)
13  enddo
14
15  write(*, *) 'Greatest common divisor : ', n
16
17  stop
18endprogram answer