/* * finds the gcd of a & b * http://people.hsc.edu/faculty-staff/tomv/Coms161/EuclidGCD.html */ Jia Tse www.egr.unlv.edu/~jjtse int gcd(int a, int b){ if (a == b) return a; if (b > a){ int temp = a; a = b; b = temp; } int r = a % b; while (r != 0){ a = b; b = r; r = a % b; } return b; }