Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: Fibonacci numbers

by claree0 (Hermit)
on Oct 02, 2001 at 14:40 UTC ( #116097=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://116097]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2022-10-06 07:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (26 votes). Check out past polls.

    Notices?