Problem 240. Project Euler: Problem 6, Natural numbers, squares and sums.
The sum of the squares of the first ten natural numbers is,
1^2 + 2^2 + ... + 10^2 = 385 The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)^2 = 55^2 = 3025 Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 - 385 = 2640.
Find the difference between the sum of the squares of the first N (where N is the input) natural numbers and the square of the sum.
Thank you to Project Euler Problem 6
Solution Stats
Problem Comments
-
2 Comments
A problem where one must be at least a little careful about floating point arithmetic. It might have been interesting if one of the test cases were x=1e5 or larger. Even more interesting if the execution time were a factor in the "score". These factors might impact how the problem would be best solved.
@ Doug Hall, I have solved all the problems in the series. However, I have not received the badge and the associated scores on completion of the series. Can you please look into this?
Solution Comments
Show commentsProblem Recent Solvers2299
Suggested Problems
-
Remove any row in which a NaN appears
8635 Solvers
-
It dseon't mettar waht oedrr the lrettes in a wrod are.
1879 Solvers
-
Getting the indices from a matrix
651 Solvers
-
Back to basics - mean of corner elements of a matrix
418 Solvers
-
Natural numbers in string form
1621 Solvers
More from this Author51
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!