Created
May 24, 2016 13:24
-
-
Save 4xes/6023b3ddac61ac199e9ebf183a3ed072 to your computer and use it in GitHub Desktop.
Fizz Buzz task
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
public class FizzBuzz { | |
public static void fizzbuzz(){ | |
String[] fizzBuzz = {null, "fizz", "buzz", "fizz buzz"}; | |
for(int i = 1; i <= 100; i++){ | |
fizzBuzz[0] = String.valueOf(i); | |
int fizz = i % 3 == 0? 1: 0; | |
int buzz = i % 5 == 0? 2: 0; | |
String out = fizzBuzz[fizz + buzz]; | |
Log.d("FizzBuzz", out); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment