Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nischalkumar/776e05ab2dbfe081207de2b1784ef80a to your computer and use it in GitHub Desktop.
Save nischalkumar/776e05ab2dbfe081207de2b1784ef80a to your computer and use it in GitHub Desktop.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
/**
* Created by nischal.k on 02/10/16.
*/
public class Main {
public static void main(String[] args) throws java.lang.Exception {
Reader.init(System.in);
int t = Reader.nextInt();
while(t-->=0) {
for(int i =1; i< Reader.nextInt(); i++) {
if(i%3==0 || i%5==0) {
if(i%3==0&&i%5==0){
System.out.println("fizzbuzz");
}else if(i%3==0) {
System.out.println("fizz");
}else {
System.out.println("buzz");
}
}
else System.out.println(i);
}
}
}
private static long recurse(Long x) {
if(x==1) return 1;
if(x==0) return 0;
if(x<0) return 0;
return recurse(x/2) + 1;
}
}
class Reader {
static BufferedReader reader;
static StringTokenizer tokenizer;
/**
* call this method to initialize reader for InputStream
*/
static void init(InputStream input) {
reader = new BufferedReader(
new InputStreamReader(input));
tokenizer = new StringTokenizer("");
}
/**
* get next word
*/
static String next() throws IOException {
while (!tokenizer.hasMoreTokens()) {
// TODO add check for eof if necessary
tokenizer = new StringTokenizer(
reader.readLine());
}
return tokenizer.nextToken();
}
static Long nextLong() throws IOException {
return Long.parseLong(next());
}
static int nextInt() throws IOException {
return Integer.parseInt(next());
}
static double nextDouble() throws IOException {
return Double.parseDouble(next());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment