Skip to content

Instantly share code, notes, and snippets.

@sklarow
Created December 21, 2021 13:57
Show Gist options
  • Save sklarow/f28a4254ffde944d9b6145480d08ec8f to your computer and use it in GitHub Desktop.
Save sklarow/f28a4254ffde944d9b6145480d08ec8f to your computer and use it in GitHub Desktop.
FizzBuzz Exercise in Java!
public class FizzBuzz {
public static void main(String[] args) {
for (int number=1; number <= 100; number++){
String result = "";
if (number % 3 == 0)
result = "Fizz";
if (number % 5 == 0)
result += "Buzz";
if (result.equals(""))
System.out.println(number);
else
System.out.println(result);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment