blob: 90cb153e8be7f5848f88ee4c1b81d9e46e919401 (
plain)
1
2
3
4
5
6
7
8
|
def sum_difference(n):
sumofsquares = 0
squareofsum = 0
for num in range(1, n+1):
sumofsquares += num * num
squareofsum += num
squareofsum = squareofsum ** 2
return squareofsum - sumofsquares
|