Finding a prime number after a given number

Posted by avd on Stack Overflow See other posts from Stack Overflow or by avd
Published on 2010-03-18T08:44:36Z Indexed on 2010/03/19 5:11 UTC
Read the original article Hit count: 413

Filed under:
|

How can I find the least prime number greater than a given number? For example, given 4, I need 5; given 7, I need 11.

I would like to know some ideas on best algorithms to do this. One method that I thought of was generate primes numbers through the Sieve of Eratosthenes, and then find the prime after the given number.

© Stack Overflow or respective owner

Related posts about primes

Related posts about algorithms