Permalink
Browse files

Second prime script.

  • Loading branch information...
1 parent 90c48e2 commit a13ba16801cfe0ec40e730dbf73493961b1565f4 @colomon colomon committed Oct 20, 2010
Showing with 19 additions and 0 deletions.
  1. +19 −0 prime-2.pl
View
@@ -0,0 +1,19 @@
+my sub next-prime(*@primes) {
+ my $i = @primes[*-1];
+ return 3 if $i == 2;
+ loop {
+ $i += 2;
+ my $prime = True;
+ for @primes {
+ if $i %% $_ {
+ $prime = False;
+ last;
+ }
+ }
+ return $i if $prime;
+ }
+}
+
+my @primes := 2, 3, &next-prime ... *;
+
+say @primes.munch(350).perl;

0 comments on commit a13ba16

Please sign in to comment.