-
-
Save magical/a16a2b795e078dd86330f815fe508150 to your computer and use it in GitHub Desktop.
prime sieve
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
#!/usr/bin/env hy | |
(def N 999) | |
(def a (+ [1 1] (* [0] N))) | |
(let [(i 1) (j 0)] | |
(while (< i N) | |
(if (= i j) (print i)) | |
(cond | |
[(> j N) (setv j 0)] | |
[(>= j i) (do (setv (get a j) 1) | |
(setv j (+ j i)))] | |
[(get a i) (setv i (inc i))] | |
[true (setv j i)]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment