Comment

Comment by ivanche

I'm a little bit surprised of "if-else if-else if" mindset in c2.com wiki entry for this. I always thought of FizzBuzz solution without a single else, like this:

  for (int i = 1; i <= 100; ++i) {
    boolean pureNumba = true;
    if (i % 3 == 0) {
      System.out.print("Fizz");
      pureNumba = false;
    }
    if (i % 5 == 0) {
      System.out.print("Buzz");
      pureNumba = false;
    }
    if (pureNumba) {
      System.out.print(i);
    }
    System.out.println();
  }
parent ivanche 12 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton