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 one hundred natural numbers and the square of the sum.
This question can be solved by using standard results for the sum to $n$ of natural numbers and the sum of squares. You can find proofs in many places on the web, including this article on brilliant.org.
Consider the following identities:
Let $a$ = sum of the first 100 natural numbers
$$a = \frac{100(100 + 1)}{2}$$
Let $b$ = sum of the squares of the first 100 natural numbers
$$b = \frac{100(100 + 1)(2 \cdot 100 + 1)}{6}$$
The required difference is given by $a^2 - b$
In terms of python:
n = 100
sum_n = n * (n + 1) // 2
sum_n_squared = n * (n + 1) * (2 * n + 1) // 6
difference = sum_n ** 2 - sum_n_squared
print(difference)
Running the above code leads to an answer of $25164150$