7 10001st Prime

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.

What is the 10 001st prime number?

#include <iostream>
#include <limits>

using namespace std;

void pause() { cin.ignore(numeric_limits<streamsize>::max(), '\n'); }

bool isPrime(int number)
{
    for (int i = 2; i < number-1; i++)
    {
        if (number % i == 0)
            return false;
    }
    return true;

}

int main()
{
    int primCount = 1;
    int potentialPrime = 3;

    while (primCount < 10001)
    {
        if (isPrime(potentialPrime) == true)
        {
            primCount++;

            if (primCount == 10001)
                break;

            potentialPrime++;
        }

        else
            potentialPrime++;

    }

    cout << potentialPrime;
    pause();
}

Solution: 104743

Last updated