Function Kata „FizzBuzz“
Write a function to return the numbers from 1 to 100. However, some of the numbers should be translated into a string according to these rules [1]:
- return „Fizz“ for multiples of 3
- return „Buzz“ for multiples of 5
- return „FizzBuzz“ for multiples of 3 and 5
The program should output the returned numbers on the console.
Example output:
1 2 Fizz 4 Buzz Fizz 7 ... 14 FizzBuz 16 ...
Variations
Also return „Fizz“ if a number contains the digit 3, e.g. 13. Do the same for „Buzz“ and 5, e.g. 51.