Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Fibonacci golf with one state variable

by aufflick (Deacon)
on Oct 05, 2008 at 11:54 UTC ( #715424=note: print w/ replies, xml ) Need Help??


in reply to Re: Fibonacci golf with one state variable
in thread Fibonacci golf with one state variable

Hey that's neat! Of course the memory usage is far from constant, but great idea. Good use of say to save a few.

Only nitpicks are that you do have explicit initialisation and the first output is zero which is not quite right. Oddly, I get no output unless I tweak it to print to STDERR which is some strange buffering difference - no idea why.

++ for thinking laterally :)


Comment on Re^2: Fibonacci golf with one state variable
Download Code
Re^3: Fibonacci golf with one state variable
by JavaFan (Canon) on Oct 05, 2008 at 13:21 UTC
    Well, I'd argue that *not* outputting zero isn't quite right. Usually, the Fibonacci sequence is defined as F(0) = 0; F(1) = 1; F(n) = F(n-1) + F(n-2), n > 1. See for instance Sloane: The On-Line Encyclopedia of Integer Sequences and Graham, Knuth and Patashnik in Concrete Mathematics. Eric Weisstein defines the sequence as starting with F(1) = F(2) = 1 and then states it's conventional to define F(0) = 0.
      Can't fault your references!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2014-08-22 10:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (153 votes), past polls