Code: Select all
# fibonacci generator code from diveintopython.org
def fibonacci(max):
a, b = 0, 1
while a < max:
yield a
a, b = b, a+b
for n in fibonacci(1000000000000000000000000000000000000000000000000000000):
print (n),
1 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000
The formula is ultra fast, and there is no problem with the computation as long as there is enough memory. The formula was cut from the example on the well known code site: http://dpaste.com/ . I only modified the code for a bigger argument and to make it compatible with Python 3.*.
If you are new to programming, start here: http://wiki.python.org/moin/BeginnersGu ... rogrammers
Another Python book: http://diveintopython.org/ that is claimed to be a Python book for experienced programmers.