'Invalid if statement termination' in Maple

236 Views Asked by At

In maple I am trying to get a list of the multiples of 3. I have attempted to use a for loop. The loop works alone; I have tested it to separately. When I attempt to use a if then statement in the do part of my for loop something goes funky. I believe it is my if statement that is off because the error I get is 'invalid if statement termination'. My coding is below any suggestions are welcome!

for a from 1 by 1 to 2000 do if type((a)/(3),integer)=true then print(a) end do;

1

There are 1 best solutions below

0
On

hint try this

$>[seq(3*k,k=1..2000/3)] $

you will get the answer

$[3,6,9,....1998] $

or

for i from 1 to 2000 do

$\;\;\;$ if i=3*floor(i/3) then

$\;\;\;\;\; $ print (i);

$\;\;\;$ endif:

end do:

you will get

3

6

9 . .

1998