0

why is wrong with my code can anyone point out?

num = int(input()) def fib(c): n = list(range(c)) for i in n: if i==0: return 0 elif i==1: return 1 else: return fib(i-1)+fib(i-2) def fibseq(a): h = 1 while h <= a: print(fib(h)) if h > a: break h += 1 print(fibseq(num)) #this is supposed to print fibonacci sequence #my output suppose to look like >>>>output 0 1 1 2 3 ... but my output prints this instead >>>>output 0 0 0 0 ... None

26th Jan 2022, 4:16 AM
Eldion Ryan
1 Answer
+ 3
Weebs No need of loop if you are doing with recursion. And also don't print first function because it will print None. just call that function def subfib(n): if n == 0: return 0 elif n == 1: return 1 return subfib(n - 1) + subfib(n - 2) ##print (subfib (10)) def fib(n): i = 0 while i < n: print (subfib (i)) i += 1 num = int(input()) fib(num)
26th Jan 2022, 5:06 AM
AÍąJ
AÍąJ - avatar