Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Easy way to list prime numbers 1 to 100

by Akhasha (Scribe)
on May 23, 2006 at 12:03 UTC ( [id://551137]=note: print w/replies, xml ) Need Help??


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

Not so easy, not so nice, and possibly buggy, as a 1 liner:
print "$_\n" for grep { $n=$_; $_==1 or ( $_%2 and ! grep { $n%$_==0 } + (2..int($n/2))) } (1..100);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-26 00:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found