Source

Project Euler / 6 / solution.py

1
2
3
4
5
def euler6():
    n = 100
    f = lambda n: sum(range(n+1))**2 - (2*n**3 + 3*n**2 + n)/6 # squared triangle, square pyramidal
    assert f(10) == 3025
    print f(n)