Find the smallest prime number greater than 5000?

I ask a few beginner level questions here frequently, not only because I am a beginner in Mathematica but sometimes these concepts are just as important as the large concepts.

I am trying to find the smallest prime number greater than 5000.
here is my code:

PrimeQ[Range[5000, 5050]]

I could test each term if I wanted, like this PrimeQ[5000], PrimeQ[5001].. ok that’s tedious

I could also produce a list of True, False(like I have in my code above) which correspond to the numbers in my range but I would still need to count to find what smallest number that is.. Is it possible to list both the number along with true or false? Does this make sense? my code only produces a list of true and falses.

The Table function is great for this:

l = Table[{i, PrimeQ[i]}, {i, 5000, 5050}]

Next, you might want to create a list of all of the primes in your range. You can do that with this, though there may be better ways:

primes = Cases[l, {_, True}][[All, 1]]

And, you can now find the smallest:

Min[primes]

In[24]:= NextPrime[5000]

Out[24]= 5003

Well I figured it out..

Clear[a];
a[m_] := Table[verprime[k ], {k, 1000, m}]

a[1050] // TableForm

thanks for any other alternatives!!

wow its that easy huh?..this is great!

thank you david

I just found a similar way using table.

thanks for the help Tim