Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

colomon (8994)

  (email not shown publicly)

Journal of colomon (8994)

Saturday January 10, 2009
02:58 PM

Sixth Script: First Working Version

[ #38254 ]
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;

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.