Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Simple primality testing

by TedYoung (Deacon)
on Nov 22, 2005 at 21:41 UTC ( #510925=note: print w/ replies, xml ) Need Help??


in reply to Simple primality testing

My favourite way to test primality is:

sub is_prime { ('1' x shift) !~ /^(11+)\1+$/ }

:-)

Ted Young

($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)


Comment on Re: Simple primality testing
Select or Download Code
Re^2: Simple primality testing
by ambrus (Abbot) on Jun 18, 2009 at 21:06 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2015-07-04 04:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls