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:
orruby '-wep 1,x=1;18.times{p x=(x/0.618).round}'
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:
Update: The following which doesn't use head is even shorterdc -e1pd[pdk+Krlxx]dsxx|head -20
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+Kd6666\>x]dsxx
Update: Even shorter and does not have the speed penalty is this:dc -e1pd[rpdk+Kdv66\>x]dsxx
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |