Question: For loop issues

I have about a year of experience in Maple, but as we know, we often come accross very simple problems that are difficult to find solutions to. Part of the problem is that I have not used conditional tests within for loops before.

I have a very large matrix, but until I solidify the algorithm, I'm practicing on a small matrix.

I created a 3 by 3 fibonacci matrix A:=<21,5,1|13,3,1|6,2,0>

I am trying to change the 1s to 0s without specific index reference. Here is my psuedocode that I hope to work on after some tips:

  • for i from 1 to 9
    if A[k] = 1 then
    A[k]=0
    end if
    end do

 

I get an error message saying "unterminated for loop," which is confusing me.

Please Wait...