Last active
July 17, 2017 19:09
-
-
Save apiv/4399737 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* the function */ | |
fib = (x) -> | |
if x < 2 | |
x | |
else | |
fib(x-1) + fib(x-2) | |
/* test it out */ | |
solutions = [] | |
for number in [0..10] | |
solutions.push ( fib number ) | |
console.log solutions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that comments in CoffeeScript are
# comment
not/* comment */
nor// comment
.Here is a more iterative and concise version: