Created
October 18, 2016 10:33
-
-
Save BedirYilmaz/9aed18fd19d14ca64564c2dbe883eb79 to your computer and use it in GitHub Desktop.
Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.
This file contains hidden or 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
def sumofsquares (n): | |
sum = 0 | |
for x in range(1,n+1): | |
sum += x*x | |
return sum | |
def squareofsum(n): | |
sum = 0 | |
for x in range(1,n+1): | |
sum += x | |
return sum*sum | |
print(squareofsum(100) - sumofsquares(100)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment