By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6^(th) prime is 13.
What is the 10001^(st) prime number?
Solution:
Function Prob007() As Long
Dim k As Integer = 1
Dim PrimeCount As Integer = 0
Dim TargetPrime As Integer = 10001
While PrimeCount < = TargetPrime
k += 1
If IsPrime(k) Then PrimeCount += 1
If PrimeCount = TargetPrime Then Return k
End While
End Function
Summary:
Simple and gets the job done.