[Tutor] Memory error - how to manage large data sets?

Kepala Pening kepalapening at gmail.com
Thu Jul 31 08:22:22 CEST 2008


Since the question is less than 2000000, I used
	b < limit.
However, to have limit = 2, perhaps I should do
	while b <= limit.

Thanks Alan for pointing it out.

----- Original Message -----
From: "Alan Gauld" <alan.gauld at btinternet.com>
To: tutor at python.org
Date: Thu, 31 Jul 2008 06:39:32 +0100
Subject: Re: [Tutor] Memory error - how to manage large data sets?

> 
> "Kepala Pening" <kepalapening at gmail.com> wrote
> 
> > def sumEvenFibonacci( limit ):
> > a, b = 1, 1  # don't waste with a = 0
> > sum = 0
> > while b < limit:
> > if b%2 == 0: sum += b
> > a, b = b, a + b
> > return sum
> > 
> > print sumEvenFibonacci( 2000000 )
> 
> Does it work for limit = 2?
> 
> Alan G.
> 
> 
> 
> 
> 


More information about the Tutor mailing list