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.
15 lines
260 B
15 lines
260 B
7 years ago
|
#! /usr/bin/env python2
|
||
|
|
||
|
# 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 xrange(0, n)]
|
||
|
|
||
|
for i in xrange(1, 11):
|
||
|
print pascal(i)
|