Skip to content

Instantly share code, notes, and snippets.

@amalloy
Forked from Eskatrem/get-prime-factors
Created August 14, 2011 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amalloy/1145191 to your computer and use it in GitHub Desktop.
Save amalloy/1145191 to your computer and use it in GitHub Desktop.
(defn get-prime-factors [n-arg]
(loop [factors (), p 2, n n-arg]
(cond (= n 1) factors
(zero? (mod n p)) (recur (cons p factors), p, (/ n p))
:else (recur factors, (inc p), n))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment