SHARE
TWEET

Untitled

a guest Oct 21st, 2017 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ##
  2. ##a = 0
  3. ##b = [1]
  4. ##while b < 50:
  5. ##    print (b)
  6. ##    a,b = b, a+b
  7. ##
  8.    
  9. def gen_fib():
  10.     num = int(input("How many fibonacci numbers would you like to generate? "))
  11.     i = 1
  12.     if num == 0:
  13.         fib = []
  14.     elif num == 1:
  15.         fib = [1]
  16.     elif num == 2:
  17.         fib = [1,1]
  18.     elif num > 2:
  19.         fib = [1,1]
  20.         while i < (num - 1):
  21.             fib.append(fib[i] + fib[i-1])
  22.             i += 1
  23.  
  24.     return fib
  25. print (gen_fib())
RAW Paste Data
Top