http://www.perlmonks.org?node_id=584092

#!/usr/bin/env ruby x=i=1;p x+=i=x-i while+1


2006-11-17 Retitled by Arunbear, as per Monastery guidelines
Original title: 'Fibonacci numbers - final shot - 24 chars'

Replies are listed 'Best First'.
Re: (OT) Fibonacci numbers in Ruby - final shot - 24 chars
by ambrus (Abbot) on Nov 15, 2006 at 07:20 UTC

    Meh, if you don't have to use perl, you can do much better: Re: Fibonacci numbers (again).

    Update: let's put them under each other to see which one is longer.

    1 2 3 123456789012345678901234567890123 dc -e1d[pdsd+ldrlxx]dsxx ruby -e'x=i=1;p x+=i=x-i while+1'
Re: (OT) Fibonacci numbers in Ruby - final shot - 24 chars
by ambrus (Abbot) on Nov 15, 2006 at 09:24 UTC

    It's also easy to shorten the ruby version by two characters

    x=i=1;loop{p x+=i=x-i}
Re: (OT) Fibonacci numbers in Ruby - final shot - 24 chars
by ikegami (Patriarch) on Nov 15, 2006 at 02:14 UTC

    That's 33, not 24 (since omitting the first line gives a compile error).

    If you want really small, try 4!

    do f

    I'm sure f can be made way smaller than ruby.

    Update: Downsized from 10

    A reply falls below the community's threshold of quality. You may see it by logging in.