Skip to content

Instantly share code, notes, and snippets.

@thinkaxelthink
Created May 20, 2013 17:14
Show Gist options
  • Select an option

  • Save thinkaxelthink/5613669 to your computer and use it in GitHub Desktop.

Select an option

Save thinkaxelthink/5613669 to your computer and use it in GitHub Desktop.
recursive fibonacci fizzbuzz
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