0
Как вывести последовательность Фибоначчи начиная с нуля до num.
Нужно вывести последовательность фибоначчи от 0 до num спомощью рекурсии Пример: num = 5 0 1 1 2 3 https://code.sololearn.com/c6Mh2XNKKbVH/?ref=app
2 Respostas
+ 4
Thanks
+ 2
Your recursive function calculates a single element. But it starts with 1 (that is the exit condition of the recursion).
If you want to start with 0, you can change it like this:
if(n <= 1):
return n
And to print all the elements you can put your print statement in a loop:
for x in range(num):
print(fibonacci(x))