I write a function to find n'th fibonancci . Codes here -
def fib(n):
res1 = 0
res2 = 0
for i in str(n):
res1 = n - 1
for j in str(n):
res2 = n - 2
return res1 + res2
Through the above code, if i enter n = 4 than it prints 5. Thats correct. But if i print n = 5 than it prints 7, it's not correct. How to fix the bugs here. Is there any logical error? Can anyone explain in details.
Don't use recursive method I want it to do with iteration.