Last active
May 18, 2022 02:20
-
-
Save kohyama/5b47be8255c1eb859f16 to your computer and use it in GitHub Desktop.
Prime Factorization in Clojure
This file contains hidden or 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 factorize [n] | |
((fn f [n [h & r :as ps]] | |
(cond (< n 2) '() | |
(zero? (mod n h)) (cons h (lazy-seq (f (quot n h) ps))) | |
:else (recur n r))) | |
n prime-numbers))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assumed that
prime-numbers
is defined byhttps://gist.github.com/kohyama/8e599b2e765ad4256f32
Example To Use: