in reply to Prime number generator

$o=1;{(grep!($o%$_),2..++$o/2)||print$o.$/;redo}
That's 48.

if we allow a shebang line:

#!/usr/bin/perl -l $o=1;{(grep!($o%$_),2..++$o/2)||print$o;redo}
45 :)

Replies are listed 'Best First'.
Re^2: Prime number generator
by liverpole (Monsignor) on Jul 17, 2006 at 20:54 UTC
    Stunning! ++

    But you realize, of course ...

    #!/usr/bin/perl -l $o=1;{(grep!($o%$_),2..$o++)||print$o;redo}

    That's 43.

    It's a little slower (but then we sacrificed speed a while back ;-))

    Update:  Make that 42 ...

    #!/usr/bin/perl -l $o=1;{grep!($o%$_),2..$o++or print$o;redo}

    s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
      Hey, making it post-increment is clever! Well spotted :)

      I had a hard time getting those stupid brackets out of there. At some point, I realised that I was being bitten by buffered output, and didn't think about them anymore.

      I think 42 is perfect!

      Cool :) ++

           s;;Just-me-not-h-Ni-m-P-Ni-lm-I-ar-O-Ni;;tr?IerONim-?HAcker ?d;print