Junior — Senior
FizzBuzz with exception generation
livecode
Task condition
The function receives an integer value and returns a byte array formed according to the following principles:
- If the input number is divisible by 3 without a remainder, the string "Fizz" is added to the array.
- If the number is divisible by 5 without a remainder, the string "Buzz" is added to the array.
- If the number is divisible by both 3 and 5, the string "FizzBuzz" is added to the array.
- If the number is not divisible by either 3 or 5, an IllegalArgumentException should be thrown.
- The implementation should be accompanied by a set of tests.