Permalink
Browse files

Rework the prime benchmark so it works on niecza.

  • Loading branch information...
1 parent e2f7fec commit c55c266e1f162aacb3b3d49e5dd6c8d75a80ae25 @colomon colomon committed May 31, 2011
Showing with 20 additions and 0 deletions.
  1. +20 −0 prime-3.pl
View
@@ -0,0 +1,20 @@
+my $two = 2;
+my $three = 3;
+my $five-four-one = 541;
+
+sub next-prime(@primes) {
+ my $i = @primes[*-1];
+ return $three if $i == $two;
+ loop {
+ $i += $two;
+ return $i unless @primes.first($i %% *);
+ }
+}
+
+my @primes = $two, $three;
+while @primes[*-1] < $five-four-one {
+ @primes.push(next-prime(@primes));
+}
+
+say ~@primes;
+

0 comments on commit c55c266

Please sign in to comment.