Suppose k is a multiple of 3. Then 2k is also a multiple of 3. So 1 + w^k + w^(2k) = 3.

Suppose k gives remainder 1 when divided by 3. Then 2k gives remainder 2 when divided by 3.

Suppose k gives remainder 2 when divided by 3. Then 2k gives remainder 1 when divided by 3.

In either of the two latter cases you get 1 + w + w^2.