mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
14 lines
279 B
CoffeeScript
14 lines
279 B
CoffeeScript
|
fibonacci = ->
|
||
|
[previous, current] = [1, 1]
|
||
|
loop
|
||
|
[previous, current] = [current, previous + current]
|
||
|
yield current
|
||
|
return
|
||
|
|
||
|
getFibonacciNumbers = (length) ->
|
||
|
results = [1]
|
||
|
for n from fibonacci()
|
||
|
results.push n
|
||
|
break if results.length is length
|
||
|
results
|