Created
December 11, 2012 02:18
-
-
Save thejambi/4255289 to your computer and use it in GitHub Desktop.
Extended FizzBuzz
This file contains hidden or 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 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