mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-02 06:46:18 -04:00
Create pascal_triangle.py
This commit is contained in:
parent
614f985f1a
commit
e15c16c55b
1 changed files with 13 additions and 0 deletions
13
math/pascal_triangle.py
Normal file
13
math/pascal_triangle.py
Normal 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]
|
Loading…
Add table
Add a link
Reference in a new issue