Advertisement
jimMoonrock

Pascal’s Triangle

Jun 25th, 2022
1,211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. numRows = [[1] * i for i in range(1, 6)]
  2.  
  3. for i in range(len(numRows)):
  4.     for j in range(len(numRows[i])):
  5.         if i > 1:
  6.           if j != 0 and j != len(numRows[i])-1:
  7.               numRows[i][j] = numRows[i-1][j-1] + numRows[i-1][j]
  8.              
  9. print(numRows)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement