[Tutor] Project Euler Problem 6

Steve Willoughby steve at alchemy.com
Thu Apr 24 22:16:10 CEST 2008


On Thu, Apr 24, 2008 at 11:13:31PM +0300, kinuthia muchane wrote:
> 	return sum([k*k for k in range(1,111)])# sum of the squares of the
> first one hundred numbers

Wouldn't the first hundred numbers be range(1,101)?

> def aux1():
> 	inter = sum([k for k in range(1,111))# square of the sum of the first

why use the list comprehension here, instead of simply saying:

    return sum(range(1,101) ** 2


-- 
Steve Willoughby    |  Using billion-dollar satellites
steve at alchemy.com   |  to hunt for Tupperware.


More information about the Tutor mailing list