1+ > * euclid .f (FORTRAN 77 )
2+ #^ source .fortran .fixed comment .line .fortran
3+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^ source .fortran .fixed comment .line .fortran
4+ > * Find greatest common divisor using the Euclidean algorithm
5+ #^ source .fortran .fixed comment .line .fortran
6+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source .fortran .fixed comment .line .fortran
7+ >
8+ > PROGRAM EUCLID
9+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
10+ # ^^^^^^^^^^^^^^^ source .fortran .fixed
11+ > PRINT * , ' A?'
12+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
13+ # ^^^^^^^^^^^^^^^^^ source .fortran .fixed
14+ > READ * , NA
15+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
16+ # ^^^^^^^^^^^^^^ source .fortran .fixed
17+ > IF (NA .LE .0 ) THEN
18+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
19+ # ^^^^^^^^^^^^^^^^^^^^^ source .fortran .fixed
20+ > PRINT * , ' A must be a positive integer.'
21+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
22+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source .fortran .fixed
23+ > STOP
24+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
25+ # ^^^^^^^^^^^ source .fortran .fixed
26+ > END IF
27+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
28+ # ^^^^^^^^^^ source .fortran .fixed
29+ > PRINT * , ' B?'
30+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
31+ # ^^^^^^^^^^^^^^^^^ source .fortran .fixed
32+ > READ * , NB
33+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
34+ # ^^^^^^^^^^^^^^ source .fortran .fixed
35+ > IF (NB .LE .0 ) THEN
36+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
37+ # ^^^^^^^^^^^^^^^^^^^^^ source .fortran .fixed
38+ > PRINT * , ' B must be a positive integer.'
39+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
40+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source .fortran .fixed
41+ > STOP
42+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
43+ # ^^^^^^^^^^^ source .fortran .fixed
44+ > END IF
45+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
46+ # ^^^^^^^^^^ source .fortran .fixed
47+ > PRINT * , ' The GCD of' , NA , ' and' , NB , ' is' , NGCD (NA , NB ), ' .'
48+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
49+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source .fortran .fixed
50+ > STOP
51+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
52+ # ^^^^^^^^ source .fortran .fixed
53+ > END
54+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
55+ # ^^^^ source .fortran .fixed
56+ >
57+ > FUNCTION NGCD (NA , NB )
58+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
59+ # ^^^^^^^^^^^^^^^^^^^^^^ source .fortran .fixed
60+ > IA = NA
61+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
62+ # ^^^^^^^^^^^ source .fortran .fixed
63+ > IB = NB
64+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
65+ # ^^^^^^^^^^^ source .fortran .fixed
66+ > 1 IF (IB .NE .0 ) THEN
67+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
68+ # ^^^^^^^^^^^^^^^^^^^^^ source .fortran .fixed
69+ > ITEMP = IA
70+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
71+ # ^^^^^^^^^^^^^^^^^ source .fortran .fixed
72+ > IA = IB
73+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
74+ # ^^^^^^^^^^^^^^ source .fortran .fixed
75+ > IB = MOD (ITEMP , IB )
76+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
77+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^ source .fortran .fixed
78+ > GOTO 1
79+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
80+ # ^^^^^^^^^^^^^ source .fortran .fixed
81+ > END IF
82+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
83+ # ^^^^^^^^^^ source .fortran .fixed
84+ > NGCD = IA
85+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
86+ # ^^^^^^^^^^^^^ source .fortran .fixed
87+ > RETURN
88+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
89+ # ^^^^^^^^^^ source .fortran .fixed
90+ > END
91+ #^^^^^^ source .fortran .fixed constant .numeric .fortran
92+ # ^^^^ source .fortran .fixed
93+ >
0 commit comments