Created
March 26, 2014 15:37
-
-
Save klen/9786199 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" 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