gcd function
Greatest common divisor of a and b. Uses Euclidean algorithm.
Audited: 2026-06-12 11:26 EDT
Implementation
int gcd(int a, int b) {
int x = a.abs();
int y = b.abs();
while (y != 0) {
final int t = y;
y = x % y;
x = t;
}
return x;
}