Skip to main content
5 of 10
changed the 100 in (int i=1;i<100;i++) to 101 because my code was printing up to 99 and not printing 100, oops. Also capitalized Fizz and Buzz

Java, 100 98 Bytes (only loop, full code is 154 bytes, see bottom)

for(int i=1;i<101;i++){String s=i%3<1?"Fizz":"";s=i%5<1?s+"Buzz":s;System.out.println(s==""?i:s);}

probably could be a lot smaller, I just started to learn java a few days ago (although I do have experience in other languages), this is the best I can do. breakdown of how it works, sorry if I get some terms wrong or explain stuff badly

for(int i=1;i<101;i++) 

just the loop, starts at 1 goes to 100

{String s=i%3<1?"Fizz":"";

Making a string called "s", equal to a value, if "i" is divisible by 3 with a remainder of less than 1 (1 character/byte smaller than checking ==0), set "s" equal to "buzz". If it isn't, set it equal to "".

s=i%5<1?s+"Buzz":s;

set s equal to a value: if i is divisible by 5 with a remainder of less than 1 , set s equal to s + "buzz", if it isn't, set it equal to itself

System.out.println(s==""?i:s);}

System.out.println is just a simple print statement, inside it, check if s is equal to "" (if s wasn't divisible by 3 or 5, it would be "") print i (the number), otherwise print s

feedback is greatly appreciated. Edit: 98 bytes for just the loop, below is what I think the full script would be, 154 bytes : (

public class f{public static void main(String args[]){for(int i=1;i<101;i++){String s=i%3<1?"Fizz":"";s=i%5<1?s+"Buzz":s;System.out.println(s==""?i:s);}}}