23 ms·
Because I know enough not to write prime testing code that resemble anything like that loop to have to care about reducing its search space. If you actually wan
by NhanH 3y ago
Because I know enough not to write prime testing code that resemble anything like that loop to have to care about reducing its search space. If you actually want to test my knowledge about prime number, you can ask and I will tell you about using some probabilistic choice instead, and that I know fast deterministic one might exist, but I am not up to date on the state of the art.
If I have to write the loop above, I am assuming it is the Fizzbuzz equivalent of your company to show that I know how to write a while loop. I am not thinking about reducing the search space because I am writing the code semi-unconscious and frankly just want to get to the next question.
- TeMPOraL 3y agoSame. Also, if I'm suspecting it's a "can they into loops" fizzbuzz test, I'd be wary of reducing the search space for the simple reason that it makes the code slightly more complex, introducing a chance to make e.g. off-by-one error, which would lose me points if the reviewer has the kind of "pedntic over irrelevant things" attitude this subthread is criticizing.