Sobes.tech
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:

  1. If the input number is divisible by 3 without a remainder, the string "Fizz" is added to the array.
  2. If the number is divisible by 5 without a remainder, the string "Buzz" is added to the array.
  3. If the number is divisible by both 3 and 5, the string "FizzBuzz" is added to the array.
  4. If the number is not divisible by either 3 or 5, an IllegalArgumentException should be thrown.
  5. The implementation should be accompanied by a set of tests.