Skip to content

Instantly share code, notes, and snippets.

@AmosAidoo
Created February 10, 2020 15:08
Show Gist options
  • Save AmosAidoo/d5d6278de51a768129103ab111fb4993 to your computer and use it in GitHub Desktop.
Save AmosAidoo/d5d6278de51a768129103ab111fb4993 to your computer and use it in GitHub Desktop.
sum = 0 #Store the sum of the numbers
sum_squares = 0 #Store the squares of the sum
for i in range(1, 101):
sum_squares = sum_squares + (i ** 2) #Compute the squares of the sum
sum = sum + i #Compute the sum
ans = sum**2 - sum_squares #Do the subtraction
print(ans) #print the answer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment