Skip to content

Instantly share code, notes, and snippets.

@cleure
Created September 15, 2015 22:20
Show Gist options
  • Save cleure/3b99b9455ad7504368f9 to your computer and use it in GitHub Desktop.
Save cleure/3b99b9455ad7504368f9 to your computer and use it in GitHub Desktop.
Pascals Triangle
import os, sys, math
def pascals_triangle(height):
data = [[1]]
width = 2
for i in range(1, height):
row = []
prev = 0
for j in data[-1] + [0]:
row.append(prev + j)
prev = j
data.append(row)
width += 1
return data
def main():
print(pascals_triangle(8))
sys.exit(0)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment