My solutions to the problems found at Project Euler.

Jump to: | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 20 | 21 | 22 | 25 | 3-2 |

Problem 6


#! /usr/bin/python
# Problem: Find the difference between the sum of squares, and the square of sums of
#          the first 100 (1-100) natural numbers.
# Approach: This one should be very straight-forward.

if __name__ == "__main__":
  numbers = range(1,101,1) #1-100
  print numbers
  
  sumofsquares = 0
  for number in numbers:
    sumofsquares += (number ** 2)
  
  print 'The sum of squares: ' + str(sumofsquares)
  
  squareofsums = 0
  for number in numbers:
    squareofsums += number
    
  squareofsums = squareofsums ** 2
  print 'The square of sums: ' + str(squareofsums)
  
  answer = squareofsums - sumofsquares
  print answer

jb