On Mon, Nov 3, 2014 at 9:07 AM, Dave Angel <da...@davea.name> wrote: > Brute force would take a few millenia, as something like > ans = sum(range( BIG ) - sum(range(1000)) > > But just knowing the math lets you simplify it to something like > ans = (1000 + BIG) * (BIG - 1000) / 2
Suggestion: Master the brute-force approach first, and use that (on small ranges) to verify the simplified version. And if you already happen to know the sum of all numbers from 1 to 100, say, then you can test both approaches against that, to be sure they're right. ChrisA -- https://mail.python.org/mailman/listinfo/python-list