Skip to content

Instantly share code, notes, and snippets.

@amoe
Created November 22, 2017 04:44
Show Gist options
  • Save amoe/e955e0776f8acc0f5f43e1320c33c404 to your computer and use it in GitHub Desktop.
Save amoe/e955e0776f8acc0f5f43e1320c33c404 to your computer and use it in GitHub Desktop.
prime factors
(defn inner [z n lim]
(cond
(> z lim)
nil
(zero? (mod n z))
(cons z
(inner (+ z 1) (/ n z) lim))
:else
(inner (+ z 1) n lim)))
(defn prime-factors [n]
(inner 2 n (Math/sqrt n)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment