Project Euler Problem 6 - Python
This is the sixth Project Euler problem solved using Python.
# euler6.py # Find the difference between the sum of the squares # of the first one hundred natural numbers # and the square of the sum. # Natural numbers are ones used for counting # (positive integers not including zero). sumofsquares = 0 squareofsums = 0 s = 0 for a in range(101): a = a**2 sumofsquares = sumofsquares + a print sumofsquares # The problem doesn't ask for this, but I thought it would be good to have. for b in range(101): s = s + b squareofsums = s * s print squareofsums # The problem doesn't ask for this, but I thought it would be good to have. answer = squareofsums - sumofsquares print answer