Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

(OT) Fibonacci numbers in Ruby - final shot - 24 chars

by sh1tn (Priest)
on Nov 15, 2006 at 01:44 UTC ( #584092=obfuscated: print w/ replies, xml ) Need Help??

#!/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'

Comment on (OT) Fibonacci numbers in Ruby - final shot - 24 chars
Download Code
Re: (OT) Fibonacci numbers in Ruby - final shot - 24 chars
by ikegami (Pope) 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

      I meant the following :)
      ruby -e 'x=i=1;p x+=i=x-i while+1'
      get it? :)
      It is Ruby and not Perl pro lang.
      Never-the-less ++


        While your first post ran in Perl, this one doesn't.

        syntax error at 584097.pl line 1, near "ruby -e " Execution of 584097.pl aborted due to compilation errors.
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}

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: obfuscated [id://584092]
Approved by grinder
Front-paged by grinder
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2014-07-10 06:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (200 votes), past polls