I have a the following code:
def fib(n):
if n < 1: return 1
return fib(n-1) + fib(n-2)
Where I would put in an array from 1-10000 as n and it would give me an error. May someone help me point out the problem?
The point of the problem is that you can't pass a list to your function. Your function wants an integer value.
>>> fib(5)
13
As expected. So you should pass just a number (n) to your function to calculate fibonacci of it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.