Are we to assume that the variable I is just a typo of the variable i? In any event, since your mult() function doesn't pass any arguments by reference (with a pointer) then calling it twice in a row and assigning it over the same variable is kinda pointless isn't it?
Code:
sum=I;
for(i=0;i<k;i++)
{
intermediary=mult(I,A); // Right here <-
sum+=intermediary; |
intermediary=mult(intermediary,A) // Why assign this value? It gets replaced -'
}
Unless you're then doing something with that intermediary value outside of the loop, which is then just poor practice leaving it in the loop for nothing.