Merging in 6 year old repo of project euler files
[sandbox] / euler / clj / 21.clj
1 (defn factors [n]
2         (filter #(zero? (mod n %))
3                 (take (- n 1) (iterate inc 1))))
4
5 (defn d [n]
6         (reduce + (factors n)))
7
8 (defn amicable? [a b]
9         (and
10                 (= a (d b))
11                 (= (d a) b)))
12
13 (defn list-length [a]
14         (if (= (first a) nil)
15                 0
16                 (+ 1 (list-length (rest a)))))