Project Euler #6: Sum square difference

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 #6.

This article features only an answer, because I’ve started writing from problem 14.

fn problem_6() -> u128 {
    let mut sum: u128 = 0;
    let mut n_sum: u128 = 0;
    for n in 1..100 {
        sum += (n as u128).pow(2);
        n_sum += n;
    }
    n_sum.pow(2) - sum
}

#[test]
fn test_problem_6() {
    assert_eq!(problem_6(), 24174150);
}

The full solution is available on GitHub.

6362616059575655545352515049484746454443424140393837363534333231302928272625242322212019181716151413121110987654321