Skip to content

Commit

Permalink
Add q66
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkun committed Sep 9, 2024
1 parent 369138f commit 6636c53
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ex/q066.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
;; https://4clojure.oxal.org/#/problem/066

(ns ex.q066)

(defn ans
"Problem 66, Greatest Common Divisor"
[x y]
(some #(when (= 0 (rem x %) (rem y %)) %) (range (min x y) 0 -1)))
12 changes: 12 additions & 0 deletions test/ex/q066_test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
;; https://4clojure.oxal.org/#/problem/066

(ns ex.q066-test
(:require [clojure.test :as t]
[ex.q066 :as sut]))

(t/deftest test-q66
(t/testing "Problem 66, Greatest Common Divisor"
(t/is (= 2 (sut/ans 2 4)))
(t/is (= 5 (sut/ans 10 5)))
(t/is (= 1 (sut/ans 5 7)))
(t/is (= 33 (sut/ans 1023 858)))))

0 comments on commit 6636c53

Please sign in to comment.