Re:Put your programming skills to the test
by cjhopman on Sunday February 12, 2012 @05:08PM
(#3583191)
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);
}
The front page challenges asked for the sum of the integers from 1 to 1000, excluding those divisible by 5 or 7. Here was my sort of smart-ass answer:
}The first guest challenge asks for the sum of the integers from 1 to 1000, excluding those that contain the digit 7.