+ 1
Nth Fibonacci Number
Nth term of Fibonacci series F(n), where F(n) is a function, is calculated using the following formula - F(n) = F(n-1) + F(n-2), Where, F(1) = F(2) = 1 Provided N you have to find out the Nth Fibonacci Number.
3 Answers
+ 5
Student ,
i suppose you are asking if someone can help you? yes - we like to help you.
to get an exact idea where you got stuck, we need to see your code.
please put it in playground and link it here. if you haven't done anything until now, please do a try by yourself and link it here.
thanks and happy coding!
+ 3
Student ,
the function call:
print(fiborecur(),num)
is not correct. the function fiborecur(n) is expecting an argument but this is missing. the call should be:
print(fiborecur(num))
you can also remove the 2 "empty" functions at the top of the code.
happy coding!
+ 2
def fiboiter():
pass
def fiborecur():
pass
def fiborecur(n):
if n==0:
return 0
elif(n==1):
return 1
else:
return fiborecur(n-1) + fiborecur(n-2)
num= int(input())
print(fiborecur(),num)