Thursday, April 24, 2014

99 Clojure Problems – 33: Determine Whether Two Positive Integers Are Coprime


(deftest p33-coprime-integers
  (is (coprime? 14 15))
  (is (not (coprime? 14 21))))


Two positive integers are coprime if the only positive integer that divides them both is 1. That is equivalent to their greatest common divisor being 1.

The solution is trivial building upon the solution to the last problem.

Read more about this series.

No comments: