Computer Science, asked by royshreya748, 4 months ago

should be greater than 5 and less than or equal
to 20,
otherwise display "INVALID INPUT"
If number given by user is space, character or
empty display "INVALID INPUT"
The text message displayed should be in exact
format as it is case sensitive.
In below example 2 is for count of even
numbers that is (2,8) and 4 is count of odd
numbers that is (1,1,3,5).
Example:
Input:
7
Output:
1 1 2 3 5 8 13
2
5​

Answers

Answered by jithuabhijithts
0

Answer:

def fib(n):

   if(n==1):

       return 1

   elif(n==2):

       return 1

   else:

       return fib(n-1)+fib(n-2)

   

try:

   n=int(input())

   e=0

   o=0

   if(5<n<=20):

       for i in range (1,n+1):

           x=fib(i)

           print(x,end=' ')

           if(x%2==0):

               e+=1

           else:

               o+=1

       print()

       print(e)

       print(o)

   else:

       print("INVALID INPUT")

except:

   print("INVALID INPUT")

Explanation:

Similar questions