Write the shortest code that either:
- Generates a Fibonacci sequence (either in standard output, or as a stream)
- Calculates, given
n
, then
th Fibonacci number
(I gave both options in case one is easier to do in your chosen language than the other.)
Edit: for the avoidance of doubt, a stream or sequence is infinite in length (I'm sorry that there are a couple of non-functional programmers who answered this question in a cheeky way). For the function that takes an n
, a reasonably large return value (the largest Fibonacci number that fits your computer's normal word size, at a minumum) has to be supported.