Created
March 9, 2013 10:08
-
-
Save grondilu/5123715 to your computer and use it in GitHub Desktop.
recursive Eratosthene sieve in Perl6
This file contains 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
multi erat(Int $N) { erat 2 .. $N } | |
multi erat(@a where @a[0] > sqrt @a[*-1]) { @a } | |
multi erat(@a) { @a[0], callwith(@a.grep: * % @a[0]) } | |
say erat 100; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment