Created
January 29, 2023 21:47
-
-
Save HeinrichHartmann/c917de72eceefb35b51126002f1a8101 to your computer and use it in GitHub Desktop.
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
with builtins; | |
let | |
div = x: y: if y / x * x == y then true else false; | |
divany = L: x: | |
if (length L) == 0 then | |
false | |
else if (div (head L) x) then | |
true | |
else | |
(divany (tail L) x); | |
cPrimes = L: candidate: max: | |
if candidate > max then | |
L | |
else if candidate == 2 then | |
(cPrimes [ 2 ] (candidate + 1) max) | |
else if (divany L candidate) then | |
(cPrimes L (candidate + 1) max) | |
else | |
(cPrimes (L ++ [ candidate ]) (candidate + 1) max); | |
primes = x: (cPrimes [ ] 2 x); | |
in primes 100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment