http://www.perlmonks.org?node_id=116097


in reply to Re: Fibonacci numbers
in thread Fibonacci numbers

OK, if you're going to make an attempt at it, then we can help

Lets see....at the start you set $a and $b to 1, and $c to $a+$b = 2

Then, on each iteration round the loop, you print out all three variables, then add 2 ($c from your initialisation) to $a and $b, then repeat.

The assignment of $c=$a+$b simply sets $c according to the values of $a and $b at the time of assignment, and does not 'recalculate' on each trip around the loop.

You will also have to rethink the calculation, as it doesn't quite work.

p.s. try using strict and warnings.