Last active
December 11, 2015 14:48
-
-
Save ashwch/4616844 to your computer and use it in GitHub Desktop.
Pascal's Triangle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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