(Only for relatively small numbers)

'Examples:

'3567-370968 = 3567

'720-2600 = 40

'4680-7200-16200 = 360

Code: Select all

`'Program to find only the greatest common divisor`

DIM AS INTEGER a,b,c,d,e,f,g,k,l

CLS

INPUT "How many numbers? (2,3,4...) = ";g

DIM z(g) AS INTEGER

CLS

FOR k = 0 TO g - 1

PRINT "Number ";k + 1;:INPUT " = ";l

z(k) = l

NEXT k

b = 0

FOR a = 0 TO g-1

IF z(a) > b THEN b = z(a)

NEXT a

e= 0

FOR c = 1 TO b

FOR d = 0 TO g - 1

IF z(d) MOD c = 0 THEN

e = e + 1

ELSE e = e -1

END IF

NEXT d

IF e = g THEN

f = c

ELSE

e = 0

END IF

NEXT c

PRINT

PRINT "G.C.D. = ";f

SLEEP

END