TITLE: The least prime greater than 2000
QUESTION [12 upvotes]: I'm a bit curious as to how "real" mathematicians would solve this problem.
"Find the least prime number greater than 2000."
Of course, I can always go brute force:
IF N IS PRIME, OUTPUT N
ELSE INCREASE N BY 1

But that's no fun. (Especially when the number is really high.)
Are there any algorithms/tricks/etc. that can help me solve this quickly and efficiently, especially if I were given large values of N?

REPLY [3 votes]: All prime numbers, except for $2$ and $3$, are of the form $6n\pm1$. Now, what's the nearest multiple of $6$ to $2000$ ? It can't be $2000$ itself, since, despite being even, the sum of its digits is not a multiple of $3$. The same holds for $2002$ as well. Then $2004$ is the answer. Let's check $2004-1=2003$. Indeed, it's prime.