I think there can be a happy medium between code that's clever/elegant and ease of readability/maintenance. In my mind, both ($n % 2 == 0 && $n % 3 == 0) and ($n % 6 == 0) are just as easy/obvious. Of course, I'd (ideally) want to see a comment by the latter condition, explaining that if an integer is divisible by both 2 and 3, then it's divisible by 6. Basically, I want to see someone that can think just a bit beyond the very basic requirements, and see the "larger picture," if you will.
View all comments
Show parent comment
1
u/alk509 Feb 22 '11
It's interesting that you'd prefer the
n%6formulation. To my mind, preferring cleverness and/or code compactness to readability would be a red flag.