What is the difference between the sum of the squares and the square of the sums?

The sum of the squares of the first ten natural numbers is,

1^{2} + 2^{2} + … + 10^{2} = 385

The square of the sum of the first ten natural numbers is,

(1 + 2 + … + 10)^{2} = 55^{2} = 3025

Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 – 385 = 2640.

Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.

### One Possible Solution: Java

public class Problem_06 {
public static void main(String args[]){
int sum_of_squares = 0;
int square_of_sum = 0;
int Sum = 0;
for(int i = 1; i < 101; i++){
int square = (int)Math.pow(i, 2);
sum_of_squares += square;
Sum += i;
}
square_of_sum = (int)Math.pow(Sum, 2);
int Difference = square_of_sum - sum_of_squares;
System.out.println("sum_of_squares = " + sum_of_squares);
System.out.println("square_of_sum = " + square_of_sum);
System.out.println("Difference is = " + Difference);
}
}

### One Possible Solution: Python

# Python version: 2.7.2
# Platform = win32
def main():
"""Finds the difference between the sum of the
squares of the first one hundred natural numbers
and the square of the sum."""
sum_of_squares = 0
square_of_sum = 0
Sum = 0
for i in range(1, 101):
square = i ** 2
sum_of_squares += square
Sum += i
square_of_sum = Sum ** 2
print "sum_of_squares = ", sum_of_squares
print "square_of_sum = ", square_of_sum
Difference = square_of_sum - sum_of_squares
print "Difference = ", Difference
if __name__ == '__main__':
main()

40.378460
-104.750975