Skip to content

Instantly share code, notes, and snippets.

@brentropy
Created October 21, 2013 20:13
Show Gist options
  • Save brentropy/7090169 to your computer and use it in GitHub Desktop.
Save brentropy/7090169 to your computer and use it in GitHub Desktop.
Pascal's Triangle in CoffeeScript
pascalsTriangle = (width) ->
set = []
prev = pascalsTriangle(width - 1) if width > 1
for i in [0...width]
if prev and prev[i-1] and prev[i]
set.push prev[i-1] + prev[i]
else
set.push 1
console.log set.join(' ')
set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment