Skip to main content

Section 4.2 Recursive Method

Recursive method is a great method in Mathematics, and is hard to understand. It helps us to find the patterns.

Activity 4.2.1.

Note that \(n!=1\cdot 2\cdot \ldots \cdot n\text{.}\) In SageMath, use factorial(n) to get the value.
I would like to ask you to write two piece of codes to reveal the command factorial.
Chanllenge QuestionI realize that factorial(100) is a huge number. Can you tell how many integers in the number?

Activity 4.2.2.

Write a code to compute the determinant. You can not use the command det().
def det2(A):
    a = A.dimensions() #输出矩阵A的行数和列数
    k = a[0]
    if a[0] != a[1]:
        print("Matrix must be square")
    elif k == 1:
        return A[0,0]
    else:
        s=0
        B = A.delete_rows([0]) # 删除A的第一行
        for j in range(k):
          s += (-1)^(j)*A[0,j]*det2(B.delete_columns([j]))
        return s