r/pythonhelp • u/Aryangupt556 • Aug 16 '22
problem with Fibonacci sequence stuck on zeros??
def series(n):
n1 = 0
n2 = 1
count = 0
if n <= 0:
print("enter a posotive integer")
if n >= 0:
while count <= n:
print(n1)
nth=n1+n2
n2 = n1
nth = n2
count+=1
series(5)
2
Upvotes
2
u/slowlycatchiemonkey Aug 16 '22
You need to understand what your own code is doing. Print out the values of each variable for series(2) and see how they change.