// from https://www.codecademy.com/resources/blog/20-code-challenges/
// Printing numbers 1 through 100 (inclusive), but for multiples of 3, we will print "Fizz" instead. If it's a multiple of 5: "Buzz". If it's a multiple of both 3 and 5: "FizzBuzz".
// We will detect the multiples of 3 and/or 5 by seeing if the quotient of the current number divided by three changes when floored (to determine whether it went into it fully, producing an integer output).
function count(){
var o = "";
for(var xint = 1;xint < 101;xint++){
if(xint / 3 == Math.floor(xint / 3)
&& xint / 5 == Math.floor(xint / 5)) o += "FizzBuzz\n"; // both 3 & 5
else if(xint / 3 == Math.floor(xint / 3)) o += "Fizz\n"; // 3
else if(xint / 5 == Math.floor(xint / 5)) o += "Buzz\n"; // 5
else o += xint + "\n";
}
console.log(o);
}
Subscribe to:
Post Comments (Atom)
Coding Challenge #54 C++ int to std::string (no stringstream or to_string())
Gets a string from an integer (ejemplo gratis: 123 -> "123") Wanted to come up with my own function for this like 10 years ago ...
-
I NEEDS MY JAVASCRIPT PLEASE :) Open txtcode .txt Save as .gct Please click the blue cheat code title to activate it, a...
-
Naruto Personality Quiz Please enable javascript ☯ Which Naruto Character Are You?
-
Useful for extensions that want to prevent event listeners from being attached or modify prototypes or functions, generally to defeat click...
No comments:
Post a Comment