Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,8 +1,9 @@
(defn proper-divisors [n]
(if (< n 4)
'(1)
(cons 1 (filter #(zero? (rem n %)) (range 2 (inc (quot n 2))))))
)
[1]
(->> (range 2 (inc (quot n 2)))
(filter #(zero? (rem n %)))
(cons 1))))
(defn perfect? [n]
(== (reduce + (proper-divisors n)) n)
)
(= (reduce + (proper-divisors n)) n))

View file

@ -1,2 +1,4 @@
(defn perfect? [n]
(= n (reduce + (for [i (range 1 n) :when (= 0 (mod n i))] i))))
(->> (for [i (range 1 n)] :when (zero? (rem n i))] i)
(reduce +)
(= n)))