Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Second prime script.

  • Loading branch information...
commit a13ba16801cfe0ec40e730dbf73493961b1565f4 1 parent 90c48e2
colomon colomon authored

Showing 1 changed file with 19 additions and 0 deletions. Show diff stats Hide diff stats

  1. +19 0 prime-2.pl
19 prime-2.pl
... ... @@ -0,0 +1,19 @@
  1 +my sub next-prime(*@primes) {
  2 + my $i = @primes[*-1];
  3 + return 3 if $i == 2;
  4 + loop {
  5 + $i += 2;
  6 + my $prime = True;
  7 + for @primes {
  8 + if $i %% $_ {
  9 + $prime = False;
  10 + last;
  11 + }
  12 + }
  13 + return $i if $prime;
  14 + }
  15 +}
  16 +
  17 +my @primes := 2, 3, &next-prime ... *;
  18 +
  19 +say @primes.munch(350).perl;

0 comments on commit a13ba16

Please sign in to comment.
Something went wrong with that request. Please try again.