Python fibonacci series
<p>I wrote a Fibonacci series using Python. Could not figure out why second program is giving wrong answer and first one right when both look same.</p>

<p>Below program gives right answer</p>

<pre><code>def fib(n):
  a,b=0,1
  while b&lt;n:
    print b
    a,b=b,a+b

fib(4)
1
1
2
3
</code></pre>

<p>Below program gives wrong answer:</p>

<pre><code>def fib(n):
  a = 0
  b = 1
  while b&lt;n:
    print b
    a = b
    b = a+b

fib(4)

1
2
</code></pre>