Factors of an integer: Difference between revisions

Content added Content deleted
No edit summary
Line 25: Line 25:


=={{header|Clojure}}==
=={{header|Clojure}}==

{{incorrect|Clojure|It needs to include the number itself in the list of factors; right now it is only producing the '''proper divisors''' of the number, which is not quite right.}}
<lang lisp>(defn factors [n]
<lang lisp>(defn factors [n]
(filter #(zero? (rem n %)) (range 1 n)))
(filter #(zero? (rem n %)) (range 1 (inc n))))


(print (factors 45))</lang>
(print (factors 45))</lang>
(1 3 5 9 15)
(1 3 5 9 15 45)


=={{header|Common Lisp}}==
=={{header|Common Lisp}}==