int iterativeGCD(int a, int b) { int tmp; while (b != 0) { if (a < b) { tmp = a; a = b; b = tmp; } tmp = b; b = a % b; a = tmp; } return a; }