Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^4: a close prime number

by blazar (Canon)
on Feb 12, 2005 at 10:51 UTC ( #430391=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub isprime {
        my $n=shift;
    ...
        $n%$_ or return 0 for (2..sqrt $n);
        1;
    }
    
  2. or download this
    sub isprime {
        (1 x shift) !~ /^1?$|^(11+?)\1+$/;
    }
    
  3. or download this
    sub nearest_prime {
        my $n=my $m=shift;
    ...
            return $m if isprime --$m;
        }
    }
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2014-12-28 08:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (179 votes), past polls