4 ms·
> I don't know why he would accept an O(n) solution to that Because it's a question used to weed out early stage candidates. It's a fizzbuzz test. The point is
by ramchip 15y ago
> I don't know why he would accept an O(n) solution to that
Because it's a question used to weed out early stage candidates. It's a fizzbuzz test. The point is not to see if the candidate knows the algorithmic complexity of arbitrary-sized integer operations, and neither is it to see if he knows whether the factorial function grows quickly enough to make a look-up table worthwhile. It's just to take a very simple function and get him to write some code in a text editor.
Or at least, that's what I read from the OP's post. Perhaps he meant otherwise.