How do I make the Fibonacci function as a recursive function ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How do I make the Fibonacci function as a recursive function ?

the given task was to make a program that takes a positive integer (num) and print the Fibonacci sequence starting from 0 num times like for example: num = 6 so the program would print out (0, 1, 1, 2, 3, 5). I made it without recursion and it succeeded, but the task actually asked me to make it with recursion but I couldn't think of a way to to do it, please help. thanks in advance <3 https://code.sololearn.com/cM3WGVlWSoIg/?ref=app

3rd Jul 2022, 11:09 PM
Tofy Fathy
Tofy Fathy - avatar
1 Answer
+ 4
The recurrence relation can simply be seen by looking at the mathematical definition of Fibonacci series. fib (0) = 0 fib (1) = 1 fib (n) = fib(n-1) + fib (n-2)
4th Jul 2022, 12:32 AM
Arsenic
Arsenic - avatar