DEV Community

Discussion on: Learning Algorithms with JS, Python and Java 5: FizzBuzz

Collapse
 
tommy3 profile image
tommy-3

Thank you for your comment. I do like your style!

I'm not sure if it's any better, but we could also rewrite the print statement as:

System.out.println(divByThree || divByFive 
        ? (divByThree ? "fizz" : "") + (divByFive ? "buzz" : "") 
        : n);