from typing import List def generate(numRows: int) -> List[List[int]]: i = 1 res = [] while i <= numRows: if i == 1: res.append([1]) i += 1 elif i == 2: res.append([1, 1]) i += 1 elif i > 2: a = -1 res.append([1, i + a, 1]) a = i + a i += 1 return res print(generate(4))