News for hackers. Stuff that matters.
Re:America’s Need for Skilled Immigrants Isn’t Going Away by 50 on Wednesday October 24, 2018 @03:40PM (#18295667)
Is the correct and most efficient way to solve it?

  #include <iostream>
  using namespace std;

  int main()
  {
      for (int i = 1; i <= 100; i++)
      {
          if ((i % 3 == 0) && (i % 5 == 0)) cout << "FizzBuzz" << endl;
          else if (i % 3 == 0) cout << "Fizz" << endl;
	  else if (i % 5 == 0) cout << "Buzz" << endl;
	  else cout << i << endl;
      }
  }
Re:America’s Need for Skilled Immigrants Isn’t Going Away by 0xffff2 on Wednesday October 24, 2018 @04:27PM (#18296047)
Off the top of my head, you can do a single mod 15 for the first case. I'm sure there are other micro optimizations, but really being able to write exactly what you did is sufficient to move on to real questions that actually have something to do with the job you're interviewing for.
Re:America’s Need for Skilled Immigrants Isn’t Going Away by Metricon on Wednesday October 24, 2018 @06:39PM (#18297079)
Technically, this would be more efficient:

  #include <iostream>
  using namespace std;
  
  int main() {
    for (int i = 1; i <= 100; i++) {
       bool t = (i % 3 == 0);
       bool f = (i % 5 == 0);
  
       if (!t && !f) { cout << i << endl; continue; }
       if (t) cout << "Fizz";
       if (f) cout << "Buzz";
       cout << endl;
    }
  }
But most interviewers are interested in the basic logic of the process.