Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def generador_fibonacci():
- fib1 = 0
- fib2 = 1
- while True:
- yield fib2
- fib1, fib2 = fib2, fib1 + fib2
- with open('fibonaccis.bin', 'wb') as f:
- contador = 1
- for fib in generador_fibonacci():
- f.write(bytes(str(fib) + ' ', 'utf-8'))
- if contador == 10:
- break
- contador += 1
- with open('fibonaccis.bin', 'rb') as f:
- print(f.read(), end='\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement