3 ms·
> Write a function that determines if a number is prime. If they didn't know what a prime number was, we would tell them. Did you also give them an algorithm t
by flukus 10y ago
> Write a function that determines if a number is prime. If they didn't know what a prime number was, we would tell them.
Did you also give them an algorithm to implement or was a brute force method good enough?
- scarface74 10y agoFirst the brute force algorithm. Then we would ask them how could they optimize it. A lot of people couldn't even get to the brute force algorithm. 1st level optimization: skip even numbers. 2nd level optimization that I was the only person to get when I had to interview for the company: loop starting at 2, and go the square root of the argument.