Skip to content

Instantly share code, notes, and snippets.

@BedirYilmaz
Created October 18, 2016 10:33
Show Gist options
  • Save BedirYilmaz/9aed18fd19d14ca64564c2dbe883eb79 to your computer and use it in GitHub Desktop.
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.
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