Created
June 2, 2015 16:16
-
-
Save DanielGGordon/c4d887c5e94c07475cf0 to your computer and use it in GitHub Desktop.
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 class FizzBuzz { | |
public static void main (String args[]) { | |
fizzBuzz(100); | |
} | |
public static void fizzBuzz (final int n) { | |
for(int i = 1; i <= n; i++) { | |
if (((i % 5) == 0) && ((i % 3) == 0)) { | |
System.out.print("fizzbuzz\n"); | |
} | |
else if ((i % 5) == 0){ | |
System.out.print("fizz "); | |
} | |
else if ((i % 3) == 0) { | |
System.out.print("buzz "); | |
} | |
else { | |
System.out.print(i + " "); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment