> For the complete documentation index, see [llms.txt](https://maksimdan.gitbook.io/interview-practice-problems/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://maksimdan.gitbook.io/interview-practice-problems/project_eular/7_10001st_prime.md).

# 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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://maksimdan.gitbook.io/interview-practice-problems/project_eular/7_10001st_prime.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
