Hello all
I have created a class called Fibs which allow you to access a specific number
in the Fibonacci series(http://en.wikipedia.org/wiki/Fibonacci_number) But it
seems to me that it is a bit inefficient, any suggestions on how to make it
more efficient?
Here is the code:
class Fibs(object):
def __init__(self):
self.fibsseq = [0, 1]
def __getitem__(self, key):
for i in xrange(key):
self.fibsseq.append(self.fibsseq[-1] +
self.fibsseq[-2])
print self.fibsseq[key]
in advance, thank you
- Emil Agerschou
_________________________________________________________________
Connect to the next generation of MSN Messenger
http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor