Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: The Sieve

by Athanasius (Archbishop)
on Mar 16, 2015 at 14:16 UTC ( #1120185=note: print w/replies, xml ) Need Help??

in reply to Not a Sieve

Hello Schmunzie,

Nice! I like the way you’ve used the x operator. By removing the subroutine I was able to golf it down to this:

for($i=2;@p<50;++$i){$x=!!($i%$_)or goto _ for@p;push@p,$i;_:print"$i, +"x$x}

16 characters saved, plus a C-style for loop and a goto! Bwahaha!

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: The Sieve
by Schmunzie (Beadle) on Mar 17, 2015 at 03:49 UTC
    Love it! I didn't know that goto existed in Perl. Oh what fun to be had. Now all we need is ALTER from COBOL (anyone remember that?)
Re^2: The Sieve
by Schmunzie (Beadle) on Mar 17, 2015 at 17:01 UTC
    Oops, at the risk of being picky, your solution doesn't print 2.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1120185]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2023-05-28 19:00 GMT
Find Nodes?
    Voting Booth?

    No recent polls found