Skip to content

Instantly share code, notes, and snippets.

@ashwch
Last active December 11, 2015 14:48
Show Gist options
  • Select an option

  • Save ashwch/4616844 to your computer and use it in GitHub Desktop.

Select an option

Save ashwch/4616844 to your computer and use it in GitHub Desktop.
Pascal's Triangle
def func(n):
lis=[[1],[1,1]]
if n in (1,2):
return lis[n-1]
for _ in range(n-2):
lis.append([1]+map(sum,zip(lis[-1],lis[-1][1:]))+[1])
return lis[-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment