3 ms·
If you're going to be a smart-ass, then go all out. function jsChallenge() { function sum(n) { var k = Math.floor(1000 / n); return n * k * (
by cjhopman 15y ago
If you're going to be a smart-ass, then go all out.
function jsChallenge() {
function sum(n) {
var k = Math.floor(1000 / n);
return n * k * (k + 1) / 2;
};
return sum(1) - sum(5) - sum(7) + sum(35);
}