in reply to Fibonacci Numbers
It doesn't just compute the series but also graphs it.perl -le'map{$_=$b.$a|"~",$b=$a,$a=$_,print}1..pop' 10
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:
That's it. The whole infinite series. Want the first 50 elements?fibs@(_:x) = 1 : 1 : zipWith (+) fibs x
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
Tom Moertel : Blog / Talks / CPAN / LectroTest / PXSL / Coffee / Movie Rating Decoder
|
|---|