The gcd program of Example 1.20 might also be written
int main() {
int i = getint(), j = getint();
while (i != j) {
if (i > j) i = i % j;
else j = j % i;
}
putint(i);
Does this program compute the same result? If not, can you fix it? Under
what circumstances would you expect one or the other to be faster?
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here