0 0 votes Please also check if the fibo(7) = 8 Python math python recursive + – 50% Accept Rate Accepted 31 answers out of 62 questions tofighi 116k points 73 79 101 answer comment Share 0 reply Please log in or register to add a comment.
Best answer 0 0 votes The correct answer is here: #function def fibonacci(n): if (n <= 0): return ("number should be positive") elif (n == 1): return(0) elif (n == 2): return(1) else: sum = fibonacci(n-1) + fibonacci(n-2) return (sum) #print result print(fibonacci(7)) tofighi answered Mar 22, 2019 • selected Mar 22, 2019 by tofighi tofighi 116k points 73 79 101 comment Share 0 reply Please log in or register to add a comment.
0 0 votes #function def fibonacci(n): if n == 1 or n == 2: return 1 else: sum = n + fibonacci(n-1) return sum #print result print(fibonacci(10)) https://repl.it/@soulwolf233/fibonacci-sequence testaccount233 answered Mar 15, 2019 testaccount233 140 points 2 comment Share See 1 comment 1 1 comment reply tofighi 116k points 73 79 101 commented Mar 22, 2019 reply flag You should correct your code as follows: sum = fibonacci(n-1) + fibonacci(n-2) 0 0 replyShare Please log in or register to add a comment.