in reply to sieve of erothenes
Here is a prime number verifier that Abigail presented at
his talk entitled
"JAPHs and Other Obscure Signatures" at YAPC 19100.
Very clever, very short, but I can't say much for the performance:
As I said, I can't claim credit for this! But it's definitely worth noting. There's an explanation of how it works on his talk web site.
This takes a number as a parameter, and checks to see whether it's prime or not. I modified it a bit to stuff @_ with primes, and got this:perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'
I think that's shorter, no?for(1..100){push@_,$_ if (1 x $_) !~ /^1?$|^(11+?)\1+$/}
As I said, I can't claim credit for this! But it's definitely worth noting. There's an explanation of how it works on his talk web site.
Alan
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: RE: sieve of erothenes
by ferrency (Deacon) on Jul 08, 2000 at 01:29 UTC | |
by maverick (Curate) on Jul 10, 2000 at 01:05 UTC |
In Section
Cool Uses for Perl