Create pascal_triangle.py

This commit is contained in:
marina 2023-07-31 12:46:59 -07:00 committed by GitHub
parent 614f985f1a
commit e15c16c55b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

13
math/pascal_triangle.py Normal file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# author: bt3gl
def get_row(self, irow: int) -> list[int]:
if irow == 0:
return [1]
result = self.get_row(irow - 1)
return [1] + [sum(_) for _ in zip(result, result[1:])] + [1]