Tuesday, 23 April 2013

gcd by subtraction - the program

I discussed the logic for this program in a previous blog. Here is the logic converted into a program for the fx-50F:-

Lbl 0:?→A:?→B:A=B=>Goto 2:If B>A:Then A→X:B→A:X→B:IfEnd:
Lbl 1:A-B→C:B→X:If X>C:Then B→A:C→B:Else C→A:IfEnd:A≠B=>Goto 1:Lbl 2:A▲Goto 0:

This program is 87 steps in length.