Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simpler solution of the iterative method
function sumMultiples(n, mul){
var sum=0;
for (var i = 0 ; i < n ; i = mul + i) {
sum += i;
}
return sum;
}
console.log(sumMultiples(1000, 5) + sumMultiples(1000, 3) - sumMultiples(1000, 15));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment