in reply to Finding the next larger prime.

You may be thinking of Euclid's proof that there are in infinite number of primes. It doesn't give you the next largest prime, or even guarantee that the result is a prime. But it does force the existence of some larger prime. You don't really need to multiply just the previous primes, you can multiply together all smaller numbers. So if you have a prime p, and you take q = 1 + p!, then either q is a prime itself, or is a multiple of some prime larger than p. But as mentioned by others, there is no smart way of getting the next largest prime. Just brute-force all the larger odd numbers, or use Eratosthenes as you said.

Update: You may be interested in reading the recent findings about primality testing being possible in polynomial-time: PRIMES is in P. But for a much more efficient (but probabilistic) algorithm for testing primality, search Google for the Miller-Rabin primality test. AFAIK it's the most commonly used algorithm, and it's a lot better then checking all the possible divisors. Unfortunately, it uses a fair amount of number theory ;)

blokhead

Replies are listed 'Best First'.
Re: Re: Finding the next larger prime.
by DrHyde (Prior) on Oct 30, 2003 at 08:51 UTC
    "Primes is in P" is the Agarwal/Saxena/Kayal paper isn't it? I'm afraid the proof is way beyond me, but does anyone have a perl or (simple) C implementation of their algorithm?

      FWIW :), This guy claims to have improved upon the efficiency of the AKS method. I don't doubt the varacity of his claim, I just can't understand enough of the paper to comment one way or the other:). I haven't succeeded in locating any implementations of the algorithm, nor even a decription that I can understand:(.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      Hooray!