Skip to content

Commit

Permalink
Add q80
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkun committed Oct 5, 2024
1 parent 54f4ee6 commit d696095
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/ex/q080.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
;; https://4clojure.oxal.org/#/problem/080

(ns ex.q080)

(defn ans
"Problem 80, Perfect Numbers"
[x]
(letfn [(divisors [y] (->> (range 1 y) (filter #(zero? (mod y %)))))]
(= x (apply + (divisors x)))))
13 changes: 13 additions & 0 deletions test/ex/q080_test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
;; https://4clojure.oxal.org/#/problem/080

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

(t/deftest test-q80
(t/testing "Problem 80, Perfect Numbers"
(t/is (= true (sut/ans 6)))
(t/is (= false (sut/ans 7)))
(t/is (= true (sut/ans 496)))
(t/is (= false (sut/ans 500)))
(t/is (= true (sut/ans 8128)))))

0 comments on commit d696095

Please sign in to comment.