FizzBuzz

FizzBuzz is a game that has gained in popularity as a programming assignment to weed out non-programmers during job interviews. The object of the assignment is less about solving it correctly according to the below rules and more about showing the programmer understands basic, necessary tools such as if-/else-statements and loops. The rules of FizzBuzz are as follows:

For numbers 1 through 100,

  • if the number is divisible by 3 print Fizz;
  • if the number is divisible by 5 print Buzz;
  • if the number is divisible by 3 and 5 (15) print FizzBuzz;
  • else, print the number.