Help:=proc(): print(` `): end: # Part 1 ---------------------------------------------- Fc:=proc(n,K) local B, b, A, i: if n=1 then return(1): fi: with(linalg): B:=matrix(2,2,[[1,1],[1,0]]): # A(n) = [F(n),F(n-1)] A(1) = [1,0] b:= [1,0]: for i from 1 to n-1 do A:=multiply(B,b): A:=op(convert(matrix(1,2,op(A)),list)): A:= A mod K: b:=A: od: op(A)[1]: end: # Part 2 ---------------------------------------------- Tc:=proc(n,K) local B, b, A, i: if n<=2 then return(1): elif n=3 then return(2): fi: with(linalg): B:=matrix(3,3,[[1,1,1],[1,0,0],[0,1,0]]): # A(n) = [F(n),F(n-1),F(n-2)] A(1) = [1,0] b:= [2,1,1]: for i from 1 to n-1 do A:=multiply(B,b): A:=convert(A,list): A:= A mod K: b:=A: od: op(A)[1]: end: