# gcd_r(a, b): greatest common divisor (recursive part) define gcd_r { if ($2 == 0) return $1 return gcd_r($2, $1 % $2) } # gcd(a, b): greatest common divisor define gcd { a = $1 + 0 b = $2 + 0 if (a < 1) a = -a if (b < 1) b = -b if (a == 0 || b == 0) return 0 return gcd_r(a, b) }