The interview question that stumped 30% of Senior Software Engineers

A few years ago, I had the opportunity to interview people for a Senior Software Engineer role.

I was dead keen to do this as I take an interest in how to interview programmers.

Amongst the questions I asked, there was one that stumped 3 of the 9 candidates. Another 3 really struggled, and the last 3 did it easily.

Here is the question:

In the language of your choice, write some code that cycles through the numbers 1 to 100 and prints out every number evenly divisible by 5.

There you have it. That’s it. The 3 that failed the question didn’t even put pen to paper. They had no idea. They were completely stumped. Didn’t even write code to cycle through the numbers 1 to 100.

(For those of you non programmers reading this post, looping through a bunch of numbers is one of the first things you learn to do, ever).

# Print the numbers 1 to 100
# range() is always <= the num in the argument so you need to add 1

for i in range(1, 101):

Now these people weren’t juniors, they were applying for a Senior Software Engineer role. And they had all worked in a role with that title before.

In my humble opinion code like this is pretty much the absolute minimum a interviewer would expect, even taking into account the stress of an interview, the unfamiliar coding environment etc.

So what was the problem? After a bit of digging it seems most of them rarely wrote custom code. They were handy with key frameworks but they spent most of their time on configuration management.

Configuration Management is a desirable skillset but this was a programming job.

Needless to say the interviews were short.

Oh, and if you are applying for a Python programming gig, don’t write your interview code in JavaScript!

Here is a satisfactory answer (you could argue that I’m over the top using the f-string – but it is intentional):

# range() is always <= the num in the argument so you need to add 1
for n in range(1, 101):
     if n%5 == 0:

2 thoughts on “The interview question that stumped 30% of Senior Software Engineers”

  1. I disagree with you solution.
    The question states “cycles through the numbers 1 to 100″ not 0 to 100, in Python the range function starts at 0.
    The solution actually needs to start at 1 and in Python it will be like so:

    for n in range(1, 101, 5):

    With result like so:

    This is not a sensible question because the answer is not really useful.

    1. I think the question is useful. It shows fundamentals of being able to program. The question is about removing the bad programmers. It is very difficult to differentiate between a average programmer who interviews well, and a good programmer who interviews averagely.

      And thanks for picking up the out by one error at the start of the loop! I’ve amended my post.

Leave a Reply