Skip to content

Instantly share code, notes, and snippets.

@viveksyngh
Created July 26, 2015 18:51
Show Gist options
  • Save viveksyngh/3273a8877de808cdaf96 to your computer and use it in GitHub Desktop.
Save viveksyngh/3273a8877de808cdaf96 to your computer and use it in GitHub Desktop.
Printing pascal traingle
def generate(A):
triangle = []
for rownum in range(A) :
nextValue = 1
row = [nextValue]
for i in range(rownum) :
nextValue = nextValue * (rownum - i) * 1 / (i + 1)
row.append(nextValue)
triangle.append(row)
return triangle
#This function will return pascal's triangle having A number of rows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment