Computer Science, asked by shabu786, 6 months ago

Display sequence of Fibonacci series until the number given by user and count total even number and off numbers in that series expect zero.
Fibonacci series should start with 1.
Total count of even numbers should be displayed in the first row and odd numbers should be displayed in next row
Number given by user for Fibonacci series should be greater than 5 and less than or equal to 20,

Answers

Answered by yesiamin6
1

Answer:

a=1;

b=1

c=0

e=0

o=0;

#n=input("ent the val of n\n");

print("fib---\n")

for i in range(1,9):

c=a+b;

a=b;

b=c;

if(c%2==0):

e=e+1

else:

o=o+1

print(c)

print("no.of even numbers in fib series=",e);

print("no.of odd numbers in fib series=",o);

Explanation:

This is the code written in Python

Here you can use n value as user choice

Instead I have used range function

The out put is attached just look at that

HOPE IT HELPS YOU

DO FOLLOW FOR MORE ANSWERS

MARK AS BRAINLIEST

Attachments:
Answered by versac
0

Answer:

Explanation:

nterms = int(input())

n1, n2 = 1, 1

count = even = odd = 0

if not nterms in range(5,21):

print("INVALID INPUT")

exit()

else:

while count < nterms:

print(n1,end=" ")

if(n1%2==0):

even+=1

else:

odd+=1

nth = n1 + n2

n1 = n2

n2 = nth

count += 1

print()

print(even)

print(odd)

Similar questions