Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
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 meditating upon the Monastery: (7)
As of 2015-01-28 07:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My top resolution in 2015 is:

















    Results (213 votes), past polls