in reply to Sieve of Eratosthenes Golf?
sub f{@_?($_[0],f(grep$_%$_[0],@_)):()}print for f 2..pop |
I used a recursive filtering approach to make it much more concise. In fact, the sub that does the work is only 39 characters.
Update: I noticed an easy way to shave a stroke (grep EXPR vs grep BLOCK), so now it's at 57. I also added code tags which I stupidly omitted.
blokhead
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Sieve of Eratosthenes Golf?
by Cody Pendant (Prior) on Apr 07, 2005 at 04:16 UTC | |
Re^2: Sieve of Eratosthenes Golf?
by dragonchild (Archbishop) on Apr 07, 2005 at 13:07 UTC |