import static java.util.stream.IntStream.rangeClosed; import java.util.List; interface FizzBuzz { static List<String> evaluate(int input) { return rangeClosed(1, input).mapToObj(FizzBuzz::determineFizzbuzz).toList(); } private static String determineFizzbuzz(int n) { switch (n%15){ case 0: return "FizzBuzz"; case 5,10: return "Buzz"; case 3,6,9,12: return "Fizz"; default: return Integer.toString(n); } } }
- import static java.util.stream.IntStream.rangeClosed;
- import java.util.List;
- interface FizzBuzz {
- static List<String> evaluate(int input) {
- return rangeClosed(1, input).mapToObj(FizzBuzz::determineFizzbuzz).toList();
- }
- private static String determineFizzbuzz(int n) {
if (n % 15 == 0) return "FizzBuzz";if (n % 3 == 0) return "Fizz";if (n % 5 == 0) return "Buzz";return Integer.toString(n);- switch (n%15){
- case 0:
- return "FizzBuzz";
- case 5,10:
- return "Buzz";
- case 3,6,9,12:
- return "Fizz";
- default:
- return Integer.toString(n);
- }
- }
- }