Created
February 2, 2020 17:54
-
-
Save typehorror/0101971952a07e0def37d263e26f20be to your computer and use it in GitHub Desktop.
Simpler solution of the iterative method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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