Skip to content

Instantly share code, notes, and snippets.

@mmowbray
Created December 30, 2016 15:59
Show Gist options
  • Save mmowbray/4781d4b82446c855ed36c02b4e7d6328 to your computer and use it in GitHub Desktop.
Save mmowbray/4781d4b82446c855ed36c02b4e7d6328 to your computer and use it in GitHub Desktop.
public class FizzBuzz {
public static void main(String[] args) {
String output;
for(int i = 1; i <= 100; i++){
if(i % 3 == 0 || i % 5 == 0){
output = "";
if(i % 3 == 0)
output += "Fizz";
if(i % 5 == 0)
output += "Buzz";
}
else{
output = "" + i;
}
System.out.println("["+i+"]: " + output);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment