Last active
September 9, 2023 11:18
-
-
Save danishi/3986d116f060761992cdedd89c34f0a6 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
| import copy | |
| init_array = [1, 0, 0, 0, 0, 0, 0, 0, 0] | |
| for i in range(1, 10): | |
| copy_array = copy.copy(init_array) | |
| if i != 1: | |
| copy_array.insert(0, 1) | |
| copy_array.pop(9) | |
| for j in range(9): | |
| init_array[j] = init_array[j] + copy_array[j] | |
| buf = [] | |
| for k in range(i): | |
| buf.append(str(copy_array[k])) | |
| print(' '.join(buf)) |
Author
danishi
commented
Sep 9, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment