Tuesday, 8 June 2021

Top 5000 python programs examples with solutions - Part 4

Program 41:

How to write  a program to print Fibonacci series of a number?

def fib(n):
   p, q = 0, 1
   while(p < n):
       yield p
       p, q = q, p + q
k=int(input('Enter the Number\n'))
for i in fib(k):
   print(i)

 

Read more »

Labels: