Skip to content

Instantly share code, notes, and snippets.

@rosenk
Created October 16, 2009 19:32
Show Gist options
  • Save rosenk/212001 to your computer and use it in GitHub Desktop.
Save rosenk/212001 to your computer and use it in GitHub Desktop.
(defn proper-devisors [n]
(filter #(= (rem n %) 0) (range 1 (inc (quot n 2)))))
(defn d [n]
(reduce + (proper-devisors n)))
(defn amicable? [n]
(let [dn (d n)
ddn (d dn) ]
(and (= n ddn) (not (= n dn)))))
(defn p21 []
(reduce + (filter amicable? (range 1 10000))))
(p21)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment