limit and step. Write down the numbers from 1 to limit inclusive and give each a sign: minus if it is a multiple of step, plus otherwise.
Return the value of the resulting sum.limit=8, step=4 → 12
4 and 8 are multiples of 4 and get a minus sign, the rest a plus: 1 + 2 + 3 − 4 + 5 + 6 + 7 − 8 = 12.
limit=3, step=7 → 6
None of 1, 2, 3 is a multiple of 7, so the answer is just 1 + 2 + 3 = 6.
limit=4, step=1 → -10
Every number is a multiple of 1, so all of them get a minus sign: −10.
limit=8, step=4
12
Run checks the first 3 tests in your browser. Submit checks all 96 tests on the server, hidden ones included.