4 ms·
Is it? Seems to require about the same knowledge as the original FizzBuzz. Even if it didn't, if a candidate couldn't write the logic to determine if a number i
by smtddr 12y ago
Is it? Seems to require about the same knowledge as the original FizzBuzz. Even if it didn't, if a candidate couldn't write the logic to determine if a number is prime or not... that's another red flag.
def is_prime(x):
if x%3 and x%2:
return True
else:
return False
print is_prime(4)
print is_prime(7)
EDIT: Oops, nevermind... you're all right and I'm wrong. I'm not fixing this code so everyone can see exactly how I screwed up.
- anon1385 12y agoI can't even tell if you are being sarcastic or not. Either way I certainly wouldn't hire you. Edit: Perhaps you should keep this in mind next time you declare 99% of programmers incompetent because they made a typo when you asked them to write code down with pencil and paper in a high pressure interview situation. It's amazing how much doing a few interviews inflates people egos.
- 0x0 12y ago25 ?
- Rapzid 12y ago0.o
- gokhan 12y agoI was just reading it again and again to see the thing I was missing :)
- AdamTReineke 12y agoRosetta Code has some examples of different methods and different languages. The most naïve way is trial division: http://rosettacode.org/wiki/Primality_by_trial_division http://rosettacode.org/wiki/Primality_by_trial_division
- cowls 12y agoThats unfortunate, you just red flagged yourself! I think its time to never ask your interview candidates that question again.
- MrQuincle 12y agoMaybe with respect to debugging someone else's code... The related interview question: "What's the first (positive) number my function will have wrong?"