"Lie Ryan" <lie.1...@gmail.com> wrote in message 
news:4c18a...@dnews.tpgi.com.au...

> Probably bending the rules a little bit:
>
>>>> sum(x**2 - 8*x - 20 for x in range(1, 2010, 5))
> 536926141

Or, letting Python do the algera for you:

>>> from sympy import var, sum
>>> dummy = var('j k')
>>> k = (5 * j) + 1
>>> t = (k)**2 + (k + 1)**2 + (k + 2)**2 - (k + 3)**2 - (k + 4)**2
>>> sum(t, (j, 0, 401))
536926141 


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to