Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 studying the Monastery: (11)
As of 2014-09-19 21:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (146 votes), past polls