go ahead... be a heretic | |
PerlMonks |
Re: Stupidest Prime Number detector ever!!by choroba (Cardinal) |
on Jun 23, 2021 at 18:56 UTC ( [id://11134210]=note: print w/replies, xml ) | Need Help?? |
If a candidate is not a prime, it must have a divisor that's less than the square root of the candidate (proof left as an exercise to the reader).
For another speed-up, skip all the even numbers but 2.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
In Section
Seekers of Perl Wisdom
|
|