Created
July 26, 2015 18:51
-
-
Save viveksyngh/3273a8877de808cdaf96 to your computer and use it in GitHub Desktop.
Printing pascal traingle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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