[Tutor] Memory error - how to manage large data sets?
Chris Fuller
cfuller084 at thinkingplanet.net
Tue Jul 29 14:23:19 CEST 2008
The original post was a little ambiguous: "I need to find the sum of all
numbers at even positions in the Fibonacci series upto 2 million."
But the project euler page
(http://projecteuler.net/index.php?section=problems&id=2) is clear: "Find the
sum of all the even-valued terms in the sequence which do not exceed four
million."
Depending on which value you are after, it may not be necessary to enumerate a
million terms of the fibonacci sequence. In fact, only about thirty are
needed.
Now if you want to do the harder problem, I suggest using GMP or some other
Numerical extension, and not Python :)
Or play some interesting math tricks. The wikipedia page on fibonaccis lists
a lot of identities that could be exploited in intriguing ways.
Cheers
More information about the Tutor
mailing list