Project Euler – Problem 6 Solution (Python)

http://projecteuler.net/index.php?section=problems&id=6

# Project Euler - Problem 6 (http://projecteuler.net/index.php?section=problems&id=6)

# Generate the sum of squares and square of sums using summation formulas, then
# subtract.
def p6():
    n = 100
    squareOfSum = ((n*(n+1))/2)**2
    sumOfSquares = (n*(n+1)*(2*n+1))/6

    print squareOfSum - sumOfSquares

No Comments »

Tina on February 1st 2009 in Project Euler

Trackback URI | Comments RSS

Leave a Reply