Created
March 5, 2019 13:59
-
-
Save bastienapp/94d576c67e463784efb5796de5bf8d2f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Mathematic { | |
public static void main(String[] args){ | |
int number = Integer.parseInt(args[0]); | |
System.out.println(fizzBuzz(number)); | |
} | |
public static String fizzBuzz(int number) { | |
if (number % 3 == 0 && number % 5 == 0) { | |
return "fizzbuzz"; | |
} | |
if (number % 3 == 0) { | |
return "fizz"; | |
} | |
if (number % 5 == 0) { | |
return "buzz"; | |
} | |
return String.valueOf(number); | |
} | |
// fizz si nombre multiple de 3 | |
// buzz si multiple de 5 | |
// fizzbuzz si multiple de 3 et de 5 | |
// "n" sinon | |
public static String fizzBuzzBastien(int n) { | |
return n % 3 == 0 && n % 5 == 0 ? "fizzbuzz" | |
: n % 3 == 0 ? "fizz" | |
: n % 5 == 0 ? "buzz" | |
: "" + n; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment