# Some simple programs for Fibonacci numbers, illustrating a "while" loop # and a number of different ways of printing ###################### def fib(n): a, b = 0, 1 while a < n: print(a), # the comma (,) is crucial to having one space, no CR a, b = b, a+b print("") def fibb(n): a, b = 0, 1 while a < n: print(a) # no comma (,) means a new line each time a, b = b, a+b print("") fib(1000) fibb(50) def fibbb(n): a, b = 0, 1 while a < n: print "Here is the next Fibonacci number: %d" % a print "Here is the next Fibonacci number: " + str(a) a, b = b, a+b print("") fibbb(100)