Created
May 20, 2013 17:14
-
-
Save thinkaxelthink/5613669 to your computer and use it in GitHub Desktop.
recursive fibonacci fizzbuzz
This file contains hidden or 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
| maxFibs = 50 | |
| fibs = [1,1] | |
| fibGen = (n) -> | |
| if fibs[n]? is false | |
| fibs[n] = fibGen(n - 1) + fibGen(n - 2) | |
| fibs[n] | |
| fizzy = (i) -> | |
| if i is undefined then i = 0 | |
| return 0 if i > maxFibs | |
| console.log ['fizz' unless fibGen(i) % 3] + ['buzz' unless fibGen(i) % 5] or fibGen(i) | |
| fizzy( i + 1 ) | |
| fizzy() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment