Created
August 26, 2020 17:02
-
-
Save IngeFrodo/e76ea1a5c16348e3eaccbb249ef1961a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FizzBuzz { | |
public List<String> fizzBuzz(int n) { | |
List<String> fizzBuzz = new ArrayList<>(); | |
for (int i = 1; i <= n; i++) { | |
if (i % 15 == 0) { | |
fizzBuzz.add("FizzBuzz"); | |
} else if (i % 5 == 0) { | |
fizzBuzz.add("Buzz"); | |
} else if (i % 3 == 0) { | |
fizzBuzz.add("Fizz"); | |
} else { | |
fizzBuzz.add(String.valueOf(i)); | |
} | |
} | |
return fizzBuzz; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment