I was working on some algorithm challenges from a coding platform, and I hit a roadblock with the "The Final Countdown" challenge. Here's what the challenge required:
Provide 4 parameters (param1, param2, param3, param4), print the multiples of param1 starting at param2 up to param3. If a multiple is equal to param4, then skip it - do not print that one. Implement this using a while loop. For example, given (3,5,17,9) you should print 6,12,15 (these are multiples of 3 between 5 and 17, except for 9).
The issue I'm facing is that my code seems to be stuck in an infinite loop. Can someone please help me identify where I went wrong? Below is my code:
function finalCount(param1, param2, param3, param4) {
var i = param2;
while (i <= param3) {
if (i == param4) {
continue;
} else if (i % param1 == 0) {
console.log(i);
}
i++;
}
}
finalCount(3, 5, 17, 9)