/** * Created by strongant on 2017/5/25. */publicclassFizbuzz {
publicstaticvoidmain(String[] args) {
intnum = 100;
printFizzbuzz(num);
}
privatestaticvoidprintFizzbuzz(intnum) {
for(inti = 1; i <= num; i++) { // count from 1 to 100if (((i % 5) == 0) && ((i % 7) == 0)) // A multiple of both?System.out.print("fizzbuzz");
elseif ((i % 5) == 0) System.out.print("fizz"); // else a multiple of 5?elseif ((i % 7) == 0) System.out.print("buzz"); // else a multiple of 7?elseSystem.out.print(i); // else just print itSystem.out.print(" ");
}
System.out.println();
}
}