Skip to content

Instantly share code, notes, and snippets.

@klen
Created March 26, 2014 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klen/9786199 to your computer and use it in GitHub Desktop.
Save klen/9786199 to your computer and use it in GitHub Desktop.
""" Project Euler problem #6. """
def problem():
""" Solve the problem.
Find the difference between the sum of the squares of the first one hundred
natural numbers and the square of the sum.
Answer: 25164150
"""
sum_of_squares = sum([n ** 2 for n in range(101)])
square_of_sums = sum(range(101)) ** 2
return square_of_sums - sum_of_squares
if __name__ == '__main__':
print problem()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment