Skip to content

Instantly share code, notes, and snippets.

@mainroach
Created March 21, 2017 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mainroach/8d35fcb4cbc84927789a2cb03772f577 to your computer and use it in GitHub Desktop.
Save mainroach/8d35fcb4cbc84927789a2cb03772f577 to your computer and use it in GitHub Desktop.
def pascalRowFast(rowIndex):
row=[0]*(rowIndex+1)
row[0] = row[rowIndex] = 1
for i in range(0, rowIndex>>1):
x = row[ i ] * (rowIndex - i) / (i + 1)
row[ i + 1 ]= row[ rowIndex - 1 - i ] = x
return row
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment