Advertisement
Guest User

fibonacci.py

a guest
Feb 19th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. print('FIBONACCI - GENERATOR')
  2. print('tippe jederzeit\n - exit - um zu beenden...')
  3.  
  4. def fibo(user_input):
  5.     x = 0
  6.     y = 1
  7.     i = 0
  8.     uin = user_input
  9.     for each in range(int(uin)):
  10.         i = i+1
  11.         if i == uin:
  12.             print(x)
  13.         x = y-x
  14.         y = x+y
  15.        
  16. while True:
  17.     user_input = input('gib an welche stelle ausgegeben wird:\n')
  18.     if user_input == 'exit':
  19.         exit()
  20.     else:
  21.         fibo(user_input)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement