Arrangements and Combinations · Lucas Theorem and the Sierpiński Triangle (Optional)

Lesson 3

Nikolai Chukhin · Alexander S. Kulikov

Let us now return to Pascal's triangle. Color an entry black if it is odd, and white if it is even.

N = 32
row = [1]

for n in range(N):
    line = " ".join("#" if value else " " for value in row)
    print(line.center(2 * N))
    row = [1] + [
        (row[i] + row[i + 1]) % 2
        for i in range(len(row) - 1)
    ] + [1]
#
# #
# #
# # # #
# #
# # # #
# # # #
# # # # # # # #
# #
# # # #
# # # #
# # # # # # # #
# # # #
# # # # # # # #
# # # # # # # #
# # # # # # # # # # # # # # # #
# #
# # # #
# # # #
# # # # # # # #
# # # #
# # # # # # # #
# # # # # # # #
# # # # # # # # # # # # # # # #
# # # #
# # # # # # # #
# # # # # # # #
# # # # # # # # # # # # # # # #
# # # # # # # #
# # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

This is the same shape again! The rest of this section explains why this happens.