Created
January 30, 2015 23:20
-
-
Save dmnugent80/6b3343615d9c7c82a091 to your computer and use it in GitHub Desktop.
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
import java.io.*; | |
import java.util.*; | |
import java.text.*; | |
import java.math.*; | |
import java.util.regex.*; | |
public class Solution { | |
public static void main(String[] args) { | |
try{ | |
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ | |
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | |
String line = br.readLine(); | |
int N = Integer.parseInt(line); | |
for (int i = 1; i <= N; i++) { | |
if (i % 3 == 0 && i % 5 == 0){ | |
System.out.println("FizzBuzz"); | |
} | |
else if (i % 3 == 0){ | |
System.out.println("Fizz"); | |
} | |
else if (i % 5 == 0){ | |
System.out.println("Buzz"); | |
} | |
else{ | |
System.out.println(i); | |
} | |
} | |
} | |
catch(Exception e){ | |
System.out.println("Exception thrown :" + e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment