in reply to Golfing a fibonacci number generator

There is short a section in Advanced Perl Programming (2nd Edition), which covers Perl golfing. The example that the author uses is the Fibonnacci series :)

It's only a page and a bit, but it's quite good because he explains it along the way. He eventually gets it down to 32 characters :)

Cheers,
Darren :)

  • Comment on Re: Golfing a fibonacci number generator

Replies are listed 'Best First'.
Re^2: Golfing a fibonacci number generator
by sh1tn (Priest) on Nov 04, 2006 at 16:07 UTC
    Yes, that's right and in realtion to this I posted an year ago the same one-liner but 27 chars long (the shortest one in the world):
    print$}+=$.=$}-$.||1while.1
    Re: Fibonacci numbers (again)


      Doesn't work - at least not for me. My best stab is 39 chars (which I'm sure can be improved):
      ($x,$y)=($y,$x+$y),print$y for$x++..19
        Yes, it works just fine (blame only yourself for your errors):
        perl -e 'print$}+=$.=$}-$.||1while.1' 1235813213455891442333776109871597258441816765109461771128657463687... +...... # and so on...