Let's see. We already have lots of fibonacci generator threads, like (OT) Fibonacci numbers in Ruby - final shot - 24 chars, Golfing a fibonacci number generator, Fibonacci Numbers, Fibonacci numbers (again)1 Fibonacci golf with one state variable1. We can use some ideas from those threads.

Firstly, modifying my dc solution, we get

dc -e1dp[pdsd+ldrlxx]dsxx|head -20

Then there's the ruby one you can adapt

ruby '-wex=i=1;20.times{p x;x+=i=x-i}'

I'll try to improve these and update this node later if I can.

Update: longer variants of the ruby line are:

ruby '-wep 1,x=1;18.times{p x=(x/0.618).round}'
or
ruby '-we20.times{|x|p((1.61803**x/1.382).round)}'

Update: I forgot to tell, but for just the first twenty numbers, the shorter dc one should work fine as well:

dc -e1pd[pdk+Krlxx]dsxx|head -20
Update: The following which doesn't use head is even shorter
dc -e1pd[rpdk+Kd6666\>x]dsxx
The following is yet one character shorter, but it takes some seconds to compute because it computes square roots to thousands of decimal places.
dc -e1pd[rpdk+Kdv66\>x]dsxx
Update: Even shorter and does not have the speed penalty is this:
dc -e1pd[pdk+KrdZ5\>x]dsxx

Update: And you can cut one more character:

dc -e1d[prdk+KdZ5\>x]dsxx

Update 2008 oct 5: added two links marked by 1.


In reply to Re: Fibo Golf challenge on 3 monkeys by ambrus
in thread Fibo Golf challenge on 3 monkeys by RMGir

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.