Advertisement
jimMoonrock

Pascal’s Triangle

Jun 25th, 2022
935
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data Copied
Advertisement