Skip to main content

Euler 0006

The Problem:

The sum of squares n is defined by the sum of natural numbers ascending, such that, sum_of_squares(10) is 385. 1^2 + 2^2 + ... 10 ^2.  
The square of sum n is defined by the square of the sum of natural numbers ascending, such that, square_of_sum(10) is 3025. (1+2+...+10)^2 = 3025
Find the difference of these 2 values where n is 100.

Considerations:

Funny enough, this doesn't even need iterative computation, there are 2 different formula we can work with:
- Sum of square: n(n+1)(2n+1)/6
- Sum of numbers (and then squared): (n(n+1)/2)^2

The Solution (No-Code!):

Which means that the final formula is (n(n+1)/2)^2 - n(n+1)(2n+1)/6
Which by hand:
- (100(101)/2)^2 - 100(101)(201)/6
- 25502500 - 338350
- 25164150