Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class test{
- public static void main(String[] args) {
- fizzBuzz(100);
- }
- private static int fizzBuzz(int n) {
- if(n == 0) {
- return 0;
- }
- System.out.println(getOutput(n));
- return fizzBuzz(n-1);
- }
- private static String getOutput(int n) {
- if(n % 3 == 0) {
- if(n % 5 == 0) {
- return "FizzBuzz";
- }
- return "Fizz";
- } else if( n % 5 == 0) {
- return "Buzz";
- }
- return n + "";
- }
- }
Add Comment
Please, Sign In to add comment