2019-07-14 22:51:31 +02:00
|
|
|
|
|
|
|
def diff_between_sum_of_squares_and_square_sum(n):
|
|
|
|
a = sum([x for x in range(1, n + 1)])**2
|
|
|
|
b = sum([x**2 for x in range(1, n + 1)])
|
|
|
|
return a - b
|
|
|
|
|
|
|
|
|
2019-07-14 05:58:38 +02:00
|
|
|
def euler_006():
|
2019-07-14 22:51:31 +02:00
|
|
|
return diff_between_sum_of_squares_and_square_sum(100)
|
|
|
|
|
2019-07-14 05:58:38 +02:00
|
|
|
|
2019-07-14 22:51:31 +02:00
|
|
|
assert(diff_between_sum_of_squares_and_square_sum(10) == 2640)
|
|
|
|
assert(euler_006() == 25164150)
|
2019-07-14 05:58:38 +02:00
|
|
|
print("e006.py: {}".format(euler_006()))
|