SUM = SUM + an = (-1/3)^n/(2*n + 1);
That is invalid syntax. You cannot have two = in the same statement.
That is invalid syntax. You need a statement separator between end and what follows.
Why whould you think that the initial values did not matter?
I would suggest to you that what you missed is that your summation is really over 0 to m instead of 1 to m, and that there are two ways you can compute that: you can either initialize the sum to 0 and loop from 0, or you can initialize the sum to 1 and loop from 1. Either way works because the term for n = 0 works out to 1.