Skip to content

Instantly share code, notes, and snippets.

@grondilu
Created March 9, 2013 10:08
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 grondilu/5123715 to your computer and use it in GitHub Desktop.
Save grondilu/5123715 to your computer and use it in GitHub Desktop.
recursive Eratosthene sieve in Perl6
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