There is this party game for children called "fizz buzz." The way it works is the first child says "one" and the second child says "two" and so on around the circle, counting up as they go. However, on a multiple of three, a child is supposed to say "Fizz!" instead. If a child ever says the wrong thing, they are out!
A harder version (which we'll see later) has an extra rule: on a multiple of five, you say "Buzz!" This means on a multiple of fifteen, you would say both words, yielding "FizzBuzz!"
For example, in JavaScript:
// Input Variables
var num = 7;
// Let's play the game!
for (var i=1; i <= num; ++i){
if (i % 3 == 0){
console.log("Fizz!");
} else {
console.log(i);
}
}
// Result:
// 1
// 2
// Fizz!
// 4
// 5
// Fizz!
// 7
blank
blank
3
blank
blank
6
blank
blank
9
blank
num variable to 20 and make it display "Fizz!" on multiples of four instead. Demonstrate your answer with screenshots.For each of the following, revise your fizzbuzz game to help you find the answer, and demonstrate with screenshots.
(Hint: You may find the RosettaCode page on FizzBuzz helpful for this last question.)