SHARE
TWEET

Untitled

a guest Jun 20th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """
  2. ** Name: ** fibonacci.py*
  3. ** Created on ** 09 June 2019*
  4. ** Author: ** Nils Arne Topland*
  5. """
  6.  
  7.  
  8. def fibonacci(n):
  9.     a, b, counter = 0, 1, 0
  10.  
  11.     while True:
  12.         if counter > n:
  13.             return
  14.         yield a
  15.         a, b = b, a + b
  16.         counter += 1
  17.  
  18.  
  19. for x in fibonacci(300):
  20.     print("Generated:", x)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top