Skip to content

Instantly share code, notes, and snippets.

@ishankhare07
Created April 3, 2019 07:44
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 ishankhare07/ee465392443e3d082c16f87356824525 to your computer and use it in GitHub Desktop.
Save ishankhare07/ee465392443e3d082c16f87356824525 to your computer and use it in GitHub Desktop.
prime number series generation in clojure
(defn prime? [x]
(def f (fn [i j]
(if (zero? (rem i j))
false
(if (<= j (quot i j))
(f i (+ j 1))
true
))))
(f x 2)
)
(take 100 (filter prime? (iterate inc 0)))
@ishankhare07
Copy link
Author

Not using argument de-structuring since it wasn't introduced in the course upto this point.
Hence I took it as a challenge to write it with (clojures) instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment