You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
259 B
14 lines
259 B
#! /usr/bin/env python3
|
|
|
|
# find the rows of pascal's triangle
|
|
|
|
def choose(n, k):
|
|
if k == 0:
|
|
return 1
|
|
return choose(n, k-1) * (n-k) / k
|
|
|
|
def pascal(n):
|
|
return [choose(n, i) for i in range(0, n)]
|
|
|
|
for i in range(1, 11):
|
|
print(pascal(i))
|
|
|