https://projecteuler.net/problem=6
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 = 552 = 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.
In [13]:
def sum_squares_first100():
total = 0
x = 1
while x in range(1, 101):
total = total + x**2
x += 1
return total
print(sum_squares_first100())
In [14]:
def comparison_sums(a, b):
return a - b
In [18]:
c = sum_squares_first100()**2
d =sum_squares_first100()
print(comparison_sums(c, d))
In [16]:
# This cell will be used for grading, leave it at the end of the notebook.
In [ ]: