5 kyu

Fibonacci Generator

906 of 920x-way

Description:

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
fib = genfib()
fib() # -> returns 0
fib() # -> returns 1
fib() # -> returns 1
fib() # -> returns 2
Mathematics
Algorithms

More By Author:

Check out these other kata created by x-way

Stats:

CreatedSep 2, 2013
PublishedSep 2, 2013
Warriors Trained1558
Total Skips98
Total Code Submissions5757
Total Times Completed920
JavaScript Completions906
CoffeeScript Completions30
Total Stars30
% of votes with a positive feedback rating81% of 156
Total "Very Satisfied" Votes110
Total "Somewhat Satisfied" Votes33
Total "Not Satisfied" Votes13
Ad
Contributors
  • x-way Avatar
  • jhoffner Avatar
  • MMMAAANNN Avatar
Ad