Generate the Fibonacci sequence in the fewest amount of characters possible. Any language is OK, except for one that you define with one operator, f
, which prints the Fibonacci numbers.
Starting point: 25 14 characters in Haskell:
f=0:1:zipWith(+)f(tail f)
f=0:scanl(+)1f
Language: C++ Compiler Errors
Characters: 205
Befunge-93
31 chars
Will output an infinite list of the Fibonacci numbers, from 0 upwards, separated by tabs (could be reduced to 29 chars by deleting
9,
in the first row, at the expense of no whitespace between numbers).Unfortunately, all the Befunge-93 interpreters I've tried seem to overflow after 65k, so the output is only correct until and including 46368 (which is F24).
Confirmed to work (with caveat above) with the Befunge-93 interpreter in Javascript and the Visual Befunge Applet Full.
I'm proud to say this is a completely original work (i.e. I did not copy this code from anyone), and it's much shorter than the Befunge solution currently on Rosetta Code.
Brainfuck, 33 characters:
BrainF**k:
That'll generate the first 5. To generate more, replace the 5 + at the beginning with more: eg:
Not the shortest, but the fastest at the time of posting. :-)
Lua - 49 chars