in reply to Easy way to list prime numbers 1 to 100

print "2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,8 +3,89,97";

Replies are listed 'Best First'.
Re^2: Easiest way to list prime numbers 1 to 100 (one-liner)
by ikegami (Patriarch) on May 23, 2006 at 17:05 UTC

    It's good practice to seperate the input from the output. It makes it easy to change the output format in the future. For example,

    my @primes = qw( 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 ); local $, = ", "; local $\ = "\n"; print @primes;

    ;)

Re^2: Easiest way to list prime numbers 1 to 100 (one-liner)
by pKai (Priest) on May 23, 2006 at 19:39 UTC

    As the claim was only to list primes below 100 easily, I found that solution actually quite O.K.

    No need to praise it as "innovative", but also no need to mock it.

    After all, the intend of the OP obviously dealt with small numbers and was not for example to show "a way to compute the 42th digit of the base 3 expansion of the 7th million prime number!"

    When dealing with small primes (say up to 1,000,000 or even beyond), using precomputed lists maybe covenient. Moreso if such lists are easily available, e.g. from this site.

Re^2: Easiest way to list prime numbers 1 to 100 (one-liner)
by Anonymous Monk on May 23, 2006 at 09:26 UTC
    that's damn best solution i've seen. simple, effective, innovative.
A reply falls below the community's threshold of quality. You may see it by logging in.