clojure: (defn gcd [a b] (if (= (mod a b) 0) b (gcd b (mod a b))))

scheme: (define (gcd a b) (if (= (modulo a b) 0) b (gcd b (modulo a b))))

lisp: (defun gcd (a b) (if (= (mod a b) 0) b (gcd b (mod a b))))

c: int gcd(int a, int b) { if ((a % b) == 0) return b; else return gcd(b, a % b); }

## Friday, February 17, 2012

### Euclid's Algorithm for finding the Greatest Common Denominator

Having some fun with Euclid's gcd algorithm this morning.

Subscribe to:
Posts (Atom)