Question: How do I add the previous answers into my for loop?

What changes should I make to make it sum up?

with(LinearAlgebra):
interface(rtablesize=infinity):

for k from 2 to 21 do
A[k]:=Matrix(18);
P[k]:=Matrix(18);
Ct[k]:=Matrix(18);
for i from 1 to (k-1) do
Ct[k]:=A[k-i].P[i];    ####what changes to make here? 
end do:
end do:

I would like to get
Ct[2]=A[1].P[1]
Ct[3]=A[2].P[1]+A[1].P[2]
Ct[4]=A[3].P[1]+A[2].P[2]+A[1].P[3]
.....
Ct[21]=A[20].P[1]+A[19].P[2]+A[18].P[3]+ ... +A[1].P[20]

 

Please help. Thank you very much

Please Wait...