Skip counting
Inputs
start and stop are whole numbers from 0 to 60, and start is at most stop. step is a whole number from 1 to 10.
Your tasks
- Create a number
totalthat starts at 0. - Use a loop that starts at
start, jumps bystepeach round, and stops once it passesstop. Add every value it lands on, includingstopif it lands there, tototal. - Complete
stepSumso it returnstotal. Return it, do not print it.
Example
With start = 2 and stop = 14 and step = 4, stepSum returns 32.
Rules
- Always include
startitself.
Test data
TEST DATA 1: start is 2, stop is 14, step is 4
TEST DATA 2: start is 5, stop is 5, step is 3
Practice focus
Loops that count, add up and multiply. Every algorithm starts here: a counter, a total and a stopping point.