Any "modern, efficient" method of finding primes is very advanced math intensive. Applied Cryptography has a good section of prime factoring and determining if a number is likely prime. Public key encryption systems based on large prime numbers (RSA) don't actually factor the large prime numbers. They generate numbers using a technique that ensures that they are probably prime. This is a great shortcut, but won't work for claiming a mathematical record like you are proposing as the number is only probably prime (extremely high certainty that it is prime, but still not %100 guaranteed).

There are many simple prime number algorightms around, unfortunately the simple ones aren't efficient. The Sieve of Erastothenes is a classic example. I do not know of any perl modules that explicitly implement prime number type functionality. Below is a simple and extermely inefficient is_prime function.

sub is_prime{ my $n=shift; return 0 if($n != int($n)); my $m=sqrt($n); for(my $c=2;$c<=$m;$c++){ return 0 if($n/$c == int($n/$c)); } return 1; }

Any way you slice it, I don't think Perl is the best language for a high performance prime number analyzer. Your best bet would be to find a language designed explicitly for doing large number math if you seriously want to go after a "largest prime number" record.


In reply to Re: redmist's Diabolical Scheme for Prime Domination by lhoward
in thread redmist's Diabolical Scheme for Prime Domination by redmist

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.