in reply to Prime list
no wonder it's unreadable... indentation rules man!
get perltidy or at least a decent editor!
I was bored, here your homework:
your basic problem is that you have to skip to the next iteration in the outer loop, thats what next LABEL does!
( did some adjustments to readability).
my @primes=(); OUTER: for ( my $i=2; @primes < 100; $i++) { for my $p (@primes) { if ($i % $p == 0) { next OUTER; } } push @primes, $i; } print "@primes";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Prime list
by AnomalousMonk (Archbishop) on Feb 08, 2015 at 22:45 UTC | |
by LanX (Saint) on Feb 08, 2015 at 22:49 UTC | |
by AnomalousMonk (Archbishop) on Feb 08, 2015 at 23:05 UTC | |
by QM (Parson) on Feb 09, 2015 at 11:04 UTC |