Skip to content

Instantly share code, notes, and snippets.

@djtrack16
Created January 13, 2015 02:17
Show Gist options
  • Save djtrack16/d8a24164f702e9f04142 to your computer and use it in GitHub Desktop.
Save djtrack16/d8a24164f702e9f04142 to your computer and use it in GitHub Desktop.
all prime factors of n
(fn primeFactors
([n] (primeFactors n 2))
([n div]
(cond
(< n div) '()
(zero? (mod n div)) (cons div (lazy-seq (primeFactors (/ n div) div)))
:else (recur n (inc div)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment