Cool one liners for the Fibonacci series? Sure, there are bunches of them. Here's one that I wrote during an email exchange on the subject in which I was dared to "do something with bitwise ops":
perl -le'map{$_=$b.$a|"~",$b=$a,$a=$_,print}1..pop' 10
It doesn't just compute the series but also graphs it.

In the same exchange, the author of the dare (who shall remain nameless) also made the wisecrack that "recursion is for wimps." That compelled me to trot out the old Haskell classic:

fibs@(_:x) = 1 : 1 : zipWith (+) fibs x
That's it. The whole infinite series. Want the first 50 elements?
Fib> take 50 fibs [1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10 +946,17711,28657,46368,75025,121393,196418,317811,514229,832040,134626 +9,2178309,3524578,5702887,9227465,14930352,24157817,39088169,63245986 +,102334155,165580141,267914296,433494437,701408733,1134903170,1836311 +903,2971215073,4807526976,7778742049,12586269025]

Fun stuff.

Cheers,
Tom


In reply to Re: Fibonacci Numbers by tmoertel
in thread Fibonacci Numbers by dReKurCe

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.