![]() And while I was not really looking, found this code. // Use Euclid's algorithm to calculate the GCD. // See en.wikipedia.org/wiki/Euclidean_algorithm. private long GCD(long a, long b) { a = Math.Abs(a); b = Math.Abs(b); for (; ; ) { long remainder = a % b; if (remainder == 0) return b; a = b;
b = remainder; }
} |
Blog >