PROGRAM gcd
  IMPLICIT NONE
  INTEGER :: a, b, c

  DO
     PRINT *, "Dose dyo mh arnhtikoys akeraioys"
     READ *, a,b
     IF (a >= 0 .AND. b>=0) EXIT
  END DO

  DO
     IF (a < b) THEN
        c = a
        a = b
        b = c
     END IF
     
     IF (b == 0) EXIT
     
     a = MOD(a,b)  
  ENDDO

  PRINT *, "O MKD einai" , a
  
END PROGRAM gcd
