euler/python/e006.py

15 lines
375 B
Python
Raw Normal View History

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
def euler_006():
2019-07-14 22:51:31 +02:00
return diff_between_sum_of_squares_and_square_sum(100)
2019-07-14 22:51:31 +02:00
assert(diff_between_sum_of_squares_and_square_sum(10) == 2640)
assert(euler_006() == 25164150)
print("e006.py: {}".format(euler_006()))