Skip to content

Instantly share code, notes, and snippets.

@thejambi
Created December 11, 2012 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thejambi/4255289 to your computer and use it in GitHub Desktop.
Save thejambi/4255289 to your computer and use it in GitHub Desktop.
Extended FizzBuzz
public static void main(String[] args) {
HashMap<Integer, String> map = new HashMap<Integer, String>();
map.put(3, "Fizz");
map.put(5, "Buzz");
map.put(7, "Pop");
for (int i = 1; i <= 100; i++) {
boolean special = false;
for (int j : map.keySet()) {
if (i % j == 0) {
System.out.print(map.get(j));
special = true;
}
}
if (!special) {
System.out.print(i);
}
System.out.println();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment