View Single Post
Old Oct 9th, 2006, 3:54 AM   #9
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
I'd be tempted to use a generator:
python Syntax (Toggle Plain Text)
  1. from itertools import islice
  2.  
  3. def fibonacci(x = 0, y = 1):
  4. while True:
  5. yield x
  6. x, y = y, x + y
  7.  
  8. for i in islice(fibonacci(), 1000):
  9. print "%d " % i,
Arevos is offline   Reply With Quote