Skip to content

Instantly share code, notes, and snippets.

@whaley
Created July 7, 2011 03:15
Show Gist options
  • Save whaley/1068842 to your computer and use it in GitHub Desktop.
Save whaley/1068842 to your computer and use it in GitHub Desktop.
public class FizzBuzz {
public static void main(String... args) {
for (int i = 1; i <= 100; i++) {
StringBuilder sb = new StringBuilder();
if (i % 3 == 0) { sb.append("Fizz"); }
if (i % 5 == 0) { sb.append("Buzz"); }
if (sb.length() == 0) { sb.append(i); }
System.out.println(sb.toString());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment