10 'HCFACTOR ----GWBasic or QBasic 20 'hh ---- Oct/85 30 GOTO 200 80 ' 90 DEFDBL M-Y 100 C = C + 1: P = N 110 N = M - N * INT(M / N) 120 M = P 130 IF N = 0 THEN RETURN 140 GOSUB 100 150 RETURN 199 ' 200 X$ = " " 210 KEY OFF: CLS 220 LOCATE 2, 20: PRINT "** HIGHEST COMMON FACTOR **" 230 LOCATE 3, 20: PRINT "***************************" 240 PRINT : PRINT "This program uses a recursive sub-routine to find the Highest" 250 PRINT "Common Factor of 2 integers using a method credited to Euclid." 255 PRINT "Enter 0,0 to end." 260 PRINT : PRINT "Enter 2 integers of up to 25 (total) digits separated by a commma" 265 LOCATE 12, 10: INPUT X, Y 270 M = X: N = Y: C = 0: IF X = 0 THEN 400 280 GOSUB 100 285 LOCATE 17, 1: PRINT X$: PRINT X$: PRINT X$ 290 LOCATE 17, 1: PRINT "The Highest Common Factor of "; X; " & "; Y; " is "; P 300 PRINT "It required "; C; " iterations." 310 LOCATE 12, 1: PRINT X$: GOTO 265 400 CLS 405 KEY ON 410 END 420 ' This seems to work only if the total number of digits 430 ' in the 2 integers is <26.