Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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

by sh1tn (Priest)
on Nov 15, 2006 at 01:44 UTC ( [id://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'

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-19 23:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found