## fibonacci sequence works, but returns results I do not expect

Question

```
nterms = int(input("How many terms? "))
n1 = 0
n2 = 1
count = 0
if nterms <= 0:
print("Please enter a positive integer")
elif nterms == 1:
print("Fibonacci sequence upto",nterms,":")
print(n1)
else:
print("Fibonacci sequence upto",nterms,":")
while count < nterms:
print(n1,end=' , ')
nth = n1 + n2
n1 = n2
```

My code prints 0 then unlimited 1's when I want it to print Fibonacci's sequence. Why am I getting this?

Show source

## Answers to fibonacci sequence works, but returns results I do not expect ( 1 )

Your issue is you are not changing the value for n2. Your missing the sum of your previous addition - this is needed for the next value of the sequence.

`n2 = nth`

is what your looking for. You will also need to increment counter or the sequence will never end?Also, stylistically, change

`print(n1,end=' , ')`

to`print(n1,end=', ')`