diff --git a/math/pascal_triangle.py b/math/pascal_triangle.py new file mode 100644 index 0000000..740ac25 --- /dev/null +++ b/math/pascal_triangle.py @@ -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]