+ 1
Can some one help me with the code coach problem Fibonacci? i understand the pattern but can't code it
6 == is the range It should output this: 011,2,3,5
3 ответов
+ 1
Firstly, did you tried to solve it? If so, why is not working, can you spot the error? If so, can you fix it?
Normally when you ask a question you should always put the problem you are facing and if you know why, also ask how can you fix it.
To solve this problem you can think like you were calculating in real life:
before:0
now:1. before: 1
result:1. now: 1. before: 1
result: 2. now: 2. before:2
result: 3. now:3
result:5
I hope I helped and Keep the good coding :)
0
Good speech
0
Tomás Ribeiro Thanks for your motivation, i already did got how to do it on math but since i read what u wrote if gave me more idea to do it my way. Thanks
Here the code:
num = int(input())
def fibonacci(n):
#complete the recursive function
fib=[]
for i in range(n):
if i < 2:
fib.append(i)
elif i >= 2:
fib.append(fib[-1]+fib[-2])
for i in fib:
print(i)
fibonacci(num)