Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

fizzbuzz java

public static String fizzBuzz(int number) {
        if (number % 3 == 0) {
            if (number % 5 == 0) {
                return "fizzbuzz";
            } else {
                return "fizz";
            }
        } else if (number % 5 == 0) {
            return "buzz";
        }
        return String.valueOf(number);
    }
 
PREVIOUS NEXT
Tagged: #fizzbuzz #java
ADD COMMENT
Topic
Name
6+1 =