Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub prime {
- my $n = 1;
- gather {
- loop {
- $n++;
- my $is-prime = True;
- loop (my $i = 2; $i <= $n.sqrt; $i++) {
- if $n mod $i == 0 {
- $is-prime = False;
- last;
- }
- }
- if $is-prime {
- take $n;
- }
- }
- }
- }
- # (2 3 5 7 11 13 17 19 23 29 31)
- prime[10] == 31 or die "Wrong value";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement