Skip to content

Latest commit

 

History

History
15 lines (11 loc) · 405 Bytes

(5 kyu) Fibonacci Generator.md

File metadata and controls

15 lines (11 loc) · 405 Bytes

Fibonacci Generator (5 kyu)

https://www.codewars.com/kata/522498c9906b0cfcb40001fc

Create a function generator genfib() that returns a function fib() which always returns the next fibonacci number on each invocation (and returns 0 when being called the first time).

Example:

var fib = genfib();
fib(); // -> returns 0
fib(); // -> returns 1
fib(); // -> returns 1
fib(); // -> returns 2