in reply to small sig line
It doesn't run on Windows the way it is, though ... how about just adding the newline character $/, and doing:
X:for(my$x=1;;){$x%$_||next(X)for(2..$x++);print$x.$/}
If you want to make it even shorter, change print to warn:
X:for(my$x=1;;){$x%$_||next(X)for(2..$x++);warn$x.$/}
Of course, since it's not "production code", you can lose the my:
X:for($x=1;;){$x%$_||next(X)for(2..$x++);warn$x.$/}
And converting from for to map saves another character, so you're down to just 50 characters:
X:for($x=1;;){map{$x%$_||next X}2..$x++;warn$x.$/}
Update: Come to think of it, you don't need the label for next, and you can switch to the "map EXPR,LIST" form of map, to bring it down to 45 characters:
for($x=1;;){map$x%$_||next,2..$x++;warn$x.$/}
Update 2: From my response below, a better golf score (44 chars) can be achieved with:
$x++;{map$x%$_||redo,2..$x++;warn$x.$/;redo}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: small sig line
by dbw (Beadle) on Aug 16, 2007 at 03:17 UTC | |
by liverpole (Monsignor) on Aug 16, 2007 at 03:51 UTC | |
by dbw (Beadle) on Aug 16, 2007 at 12:05 UTC | |
by dbw (Beadle) on Aug 16, 2007 at 15:21 UTC | |
|
Re^2: small sig line
by goibhniu (Hermit) on Aug 18, 2007 at 09:17 UTC |