1,131 views
0 0 votes
Please also check if the fibo(7) = 8
50% Accept Rate Accepted 31 answers out of 62 questions

2 Answers

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))
selected by
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

Related questions

0 0 votes
1 1 answer
585
585 views
tofighi asked Oct 18, 2018
585 views
If a big company such as Google behind it, with high probability it is a great library such as TensorFlow. But in general how can I found out?
1 1 vote
1 1 answer
741
741 views
0 0 votes
0 0 answers
532
532 views
Ziva asked Jul 31, 2020
532 views
https://ibb.co/MgXvrkL