If I was your teacher I would just tell you to use a loop, leaving you to decide what you aren't allowed to do.
In this case you need to read the documentation for the colon function. It will tell you how you can introduce a step size.
You should also avoid the use of sum as a variable name, as you are likely to use the sum function elsewhere in your code. If it already is a variable, that will cause strange issues.