Filtered Fibonacci
from series import fibonacci
even = ( fib for fib in fibonacci() if fib % 2 == 0 )
for e in even:
print(e)
if e > 40:
break
Output:
0
2
8
34
144
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
from series import fibonacci
even = ( fib for fib in fibonacci() if fib % 2 == 0 )
for e in even:
print(e)
if e > 40:
break
Output:
0
2
8
34
144