; ****************************************************************
; Greatest Common Divisor
; ****************************************************************
; Greatest Common Divisor, Sourcebook for Programmable Calculators
;  (Pages 1-6 thru 1-8)

#EMULATOR c:\ti-59\prg2\gcd\gcd.t59
#LISTING c:\ti-59\prg2\gcd\gcd.lst
#POCKETPC c:\ti-59\prg2\gcd\gcd.ti

; Stores a in R01.
; ----------------
lbl a
sto 1 r/s

; Stores b in R02.
; ----------------
lbl b
sto 2 r/s

; Divides a by b and finds r1.  Advances b to R01 and stores r in
; R02.  Then tests r to see if r=0; if not, program loops back to
; C and repeats until r=0.  Program then calls r(n-1) [GCD] from
; R01 and stops.
; ---------------------------------------------------------------
lbl c
rcl 1 / rcl 2 = int * rcl 2
+/- + rcl 1 = exc 2 sto 1
rcl 2 x%t 0 inv eq c "GCD line>> rcl 1 mixline r/s
 
#end
