2 ms·
Given that most people would be answering this in some form of imperative language, I'd say that any solution which includes "for", some "if"s or a "switch", an
by jff 17y ago
Given that most people would be answering this in some form of imperative language, I'd say that any solution which includes "for", some "if"s or a "switch", and a few judiciously placed modulus operations would be sufficient. Actually, if I were giving the test, I'd probably ask for pseudocode anyway.