Wednesday, 5 December 2012

Week 7-GCD on DrRocket


GCD is the faster way to find the common demonstrator. Greatest Common Denominator (GCD) is developed by Euclid, and it can be written in DrRocket as

(define (GCD m n)
  (cond
    [(zero? n) m]
    [else (GCD n (remainder m n))]))

For example, (GCD 35 15)-> (GCD 15 5)->(GCD 5 0) then the common denominator is 5.

No comments:

Post a Comment