Created
November 22, 2017 04:44
-
-
Save amoe/e955e0776f8acc0f5f43e1320c33c404 to your computer and use it in GitHub Desktop.
prime factors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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