Menu
×
×
Correct!
Exercise:How can we make this fibonacci() function recursive?
print(0)
print(1)
count = 2
def fibonacci(prev1, prev2):
global count
if count <= 19:
newFibo = prev1 + prev2
print(newFibo)
prev2 = prev1
prev1 = newFibo
count += 1
@(9)(prev1, prev2)
else:
return
fibonacci(1,0)
print(0)
print(1)
count = 2
def fibonacci(prev1, prev2):
global count
if count <= 19:
newFibo = prev1 + prev2
print(newFibo)
prev2 = prev1
prev1 = newFibo
count += 1
fibonacci(prev1, prev2)
else:
return
fibonacci(1,0)
Not CorrectClick here to try again. Correct!Next ❯ |
This will reset the score of ALL 43 exercises.
Are you sure you want to continue?