function gcd( integer a, integer b ) { x = a; y = b; while ( y != 0 ) { r = x mod y; x = y; y = r; } return x; }