A non-recursive GCD algorithm is given on the right side.
Java does not have “repeat ... until ” command, so the command “do ... while ” is used instead.
|
|
procedure GCD( int a, int b )
repeat
gcd = a mod b
a = b
b = gcd
until a mod b == 0
return gcd
end procedure
|
|