Sixth Script: First Working Version

colomon on 2009-01-10T19:58:35

Find all the primes to 200. Straightforward sieve implementation. Lacking some elegance, but when I attempted to use :by(2) it didn't work for me.

my @nonprime;

say 2; for 3..200 -> $x, $y { unless (@nonprime.exists($x)) { say $x; my $i; loop ($i = $x; $i < 200; $i += 2 * $x) { @nonprime[$i] = 1; } } }