6
$\begingroup$

Can anybody point me an algorithm to generate prime numbers, I know of a few ones (Mersenne, Euclides, etc.) but they fail to generate much primes...

The objective is: given a first prime, generate the 'n' next primes. But thanks for the link ;-)

for example : primes( 17, 50 ) -> Generate 50 consecutive primes starting at 17 

and do not fail any prime in this 50... no holes!

  • 4
    How about http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes? Could you be more specific about what properties you want the algorithm to have?2012-06-30
  • 0
    The intention of the algorithm is: Given a first/seed prime number, generate the next 'n' primes2012-07-01
  • 0
    I Know the "Sieve of Eratostenes", it was probably one of the first I understood fully. I can use it to this purpose but demands many interactions... I'm looking for a more elegant solution... formula based perhaps...2012-07-01
  • 0
    Will you please edit your question to add relevant information about what you are actually looking for?2012-07-01

7 Answers 7