[4Clojure]解题记录-#80

Perfect Numbers
 

Difficulty: Medium
Topics:  
 
A number is "perfect" if the sum of its divisors equal the number itself. 6 is a perfect number because 1+2+3=6. Write a function which returns true for perfect numbers and false otherwise.
 
(= (__ 6) true)
 
(= (__ 7) false)
 
(= (__ 496) true)
 
(= (__ 500) false)
 
(= (__ 8128) true)
 
解长度:47
#(= (apply + (for [i (range 1 %) :when (= 0 (mod % i))] i)) %)
posted @ 2014-12-01 20:32  TomAndRainy  阅读(101)  评论(0编辑  收藏  举报