Recursive Fibonacci
There is this question in Python Core , how should I code only in the function block to print the numbers only once? ---------- The Fibonacci sequence is one of the most famous formulas in mathematics. Each number in the sequence is the sum of the two numbers that precede it. For example, here is the Fibonacci sequence for 10 numbers, starting from 0: 0,1,1,2,3,5,8,13,21,34. Write a program to take N (variable num in code template) positive numbers as input, and recursively calculate and output the first N numbers of the Fibonacci sequence (starting from 0). Sample Input 6 Sample Output 0 1 1 2 3 5 If you are making the Fibonacci sequence for n numbers, you should use n<=1 condition as the base case. ---------- I passed with this code, but it is not a recursive function. num = int(input()) def fibonacci(n): #complete the recursive function p, q = 0, 1 for i in range(n): print(p) p, q = q, p + q fibonacci(num)