Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -0,0 +1,24 @@
|
|||
function isHarshad(n) {
|
||||
var s = 0;
|
||||
var n_str = new String(n);
|
||||
for (var i = 0; i < n_str.length; ++i) {
|
||||
s += parseInt(n_str.charAt(i));
|
||||
}
|
||||
return n % s === 0;
|
||||
}
|
||||
|
||||
var count = 0;
|
||||
var harshads = [];
|
||||
|
||||
for (var n = 1; count < 20; ++n) {
|
||||
if (isHarshad(n)) {
|
||||
count++;
|
||||
harshads.push(n);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(harshads.join(" "));
|
||||
|
||||
var h = 1000;
|
||||
while (!isHarshad(++h));
|
||||
console.log(h);
|
||||
Loading…
Add table
Add a link
Reference in a new issue