Project Euler #7: 10001st prime

This article is part of a series where I'll be diving head first into the Project Euler puzzles. I want to document the challenge of solving such a puzzle and how I got to the answer. I want to prefix this by stating that I can't cheat for any of these challenges; with that I mean I can't look up any other implementations online. After the implementation, I will validate the answer by using this document or a similar sheet.

In this article I'll be solving: Project Euler #7.

Taking the is_prime() function from the “Largest prime factor”, we can solve this relatively easily:

fn problem_7() -> u64 {
    let mut start = 1;
    let mut index = 0;

    loop {
        start += 1;

        if is_prime(start) {
            index += 1
        }

        if index == 10001 {
            break start
        }
    }
}

#[test]
fn test_problem_7() {
    assert_eq!(problem_7(), 104743);
}

The full solution is available on GitHub.

6362616059575655545352515049484746454443424140393837363534333231302928272625242322212019181716151413121110987654321