fizzbuzz java

Solutions on MaxInterview for fizzbuzz java by the best coders in the world

showing results for - "fizzbuzz java"
Sara
22 Apr 2019
1public static String fizzBuzz(int number) {
2        if (number % 3 == 0) {
3            if (number % 5 == 0) {
4                return "fizzbuzz";
5            } else {
6                return "fizz";
7            }
8        } else if (number % 5 == 0) {
9            return "buzz";
10        }
11        return String.valueOf(number);
12    }
Maximilian
20 Mar 2017
1class FizzBuzz {
2  public static void main(String[] args) {
3    for (int i=1; i<=100; i++) {
4      if (i%15==0) {
5        System.out.println("FizzBuzz");
6      } else if (i%5==0) {
7        System.out.println("Buzz");
8      } else if (i%3==0) {
9        System.out.println("Fizz");
10      } else {
11        System.out.println(i);
12      }
13    }
14  }
15}