Stack OverflowShould entry level programmers be able to answer FizzBuzz?
[+69] [41] Bryan Rowe
[2009-10-28 15:21:12]
[ jobs interview-questions entry-level fizzbuzz ]

When interviewing entry level developers, I have used the FizzBuzz question [1] as a type of acid test. Generally, I ask for a solution in pseudo-code or any language of their choice. If someone can't answer this question -- or get reasonably close, the interview generally ends shortly thereafter and we don't progress to more interesting code questions.

In your opinion, is it fair/appropriate/accurate to filter entry-level staff in this manner? Should the average four year college graduate have a reasonable enough foundation to be able to throw up a pseudo-code solution of FizzBuzz?

(18) the interview generally ends shortly thereafter... Generally? Really? - JRL
(5) Well, out of politeness yes. I stop asking programming questions and see if they have any questions and then conclude the interview. I suppose I could just walk out of the room when they can't solve the problem (I'm tempted sometimes), but I don't. - Bryan Rowe
(5) I think that the question isn't whether it is fair (sure it is) but whether it's effective. Personally, if I were you I'd even skip the hoop-jumping FizzBuzz code test in favor of something more targeted at the actual job content. Or perhaps put the FizzBuzz test in the -application- process, so you can scan for initial failures there? Though the solution would inevitably be cribbed, at least it would show that they can do their research. - Tchalvak
(49) Graduates? First year students should be able to code it without much hand holding. - jmucchiello
(1) I didn't realize where this came from, but I was asked this question recently at an interview in Chicago. I thought it was a joke, it was two easy, but I did use 3 if statements to do it. - James Black
(6) I always keep a second question of similar level ready. Sometimes it's just nervosity of the interview situation that makes one fail (and I've seen candidates write scary code with bold confidence) - peterchen
This was the second of two programming questions. The first was to be able to decode, so foo => baa, as f maps to b, etc, but I had mentioned an assumption where I used one dictionary, so I ended up using a second to get it completely answered. - James Black
(2) First year students? 4th grade BASIC was harder than that on a C64. (Yes, it was optional.) - György Andrasek
Code Golf here we come ... - Tim Post
@Tim: Easy and optimal: "f" in Jon Skeet's language.… - community_owned
the problem people will run into is with no knowing mod ... I haven't had to use MOD in an application for maybe 7-8 years at work. - John Nicholas
[+133] [2009-10-28 15:22:34] Developer Art [ACCEPTED]

Of course he should. It is as basic as it gets.

Can't really believe someone couldn't write even a pseudocode for that.

(19) I've interviewed people with 20 years of experience that have real issues with this problem -- it will never cease to amaze me. - Bryan Rowe
(1) In the past I used to get asked about OOP concepts quite often. Interviewers declared they had many candidates who couldn't understand them. That was amazed me even more than that. - Developer Art
(8) I once had an interviewee tell me that the game Battleship could not be constructed in an OO fashion. Scary. - Bryan Rowe
(7) What have these people been doing for 20 years? Actually, they have an amazing skill: Holding on to a programming job for 20 years without even the most rudimentary coding skill is itself impressive... Or, an indictment of the where they used to work... - dicroce
Programming is a mystical art not well understood by non-programmers. When the program doesn't work, even if it's in a fundamental way, it can just be described as a "bug" or a need for an "enhancement". Except for some types of abstract art, it's about the only area where you can submit an empty box with "product" scribbled on the side, and convince the buyer they are getting what they asked for (I've seen this is taken to absurd levels with in house programming) - David
(3) I think if a modern artist can display a box and call it done, why not a programmer? It'll probably take more work for the programmer. :D - Tchalvak
(2) Usually about halfway through sorting a candidate list, I get pretty short when someone can't pass the FizzBuzz test or the alternatively of mocking out selecting a row from SQL and printing the output. While back I had someone spend a half a hour stalling for time while I tried to remember the correct syntax for "Select * from fooTable where id = 10". I said something to the extent of "So did you learn to program on the back of a cereal box?" and their response was PHP was just to complicated a language vs. Java. - David
(2) @dicroce As an over the phone consult I spoke with a client who was trying to figure out what to do with his current dev team. For the last 15 years this team of 5, each billing +100$/hour has written all of the companies webservices in c++ backed CGI scripts. I honestly didn't know how to tell him that this company has spent $32 million for a dinosaur preserve. - David
(1) @David There's nothing inherently wrong with C++ for web based services depending on what they are doing (integrating with existing C++ code for example), but I suspect yeah you'd end up in a corner with no way out. - Kurt
(2) Sometimes going to a job interview puts a lot of nervousness, that's the reason that many people can't answer that question, when in a normal circumstance they'd do just fine. It happened to me with a simpler question, and I am an excellent programmer. - piotr
[+81] [2009-10-28 17:22:44] David

Yes. A million times yes (of which you'll have by the time everyone has posted their yes answer).

The entire point of FizzBuzz is to break down programming to the simplest possible test - do you understand how to communicate a task to a computer (by breaking it down into logical actions and decisions that do not require intuitive leaps).

If a person cannot meet this most basic requirement, they are not the programmer they claim to be.

If they can prove they have had any training at all (most bright people should be able to complete this, at least in pseudo code, after just their first week in a high school programming course) then they are not suitable to be a programmer at all - their brain just doesn't work the way it needs to (you can teach someone for 50 years and they still won't be Mozart).

Yes, you will get people who have 10 years of experience working as a programmer (and are not just faking their resume). They have 10 years because someone, maybe like you, decided that they must be able to program and hired them (because they had 8 year/5 years/2 years/a degree in programming). And thanks to the tools meant to help programmers do the simple things faster (like drag and drop designers), they are able to do the bare minimum needed to create the impression of work (which other programmers must make minor "bug fixes" for it to actually do what it is supposed to).

You want to stop having to interview people like this? Stop hiring them under the impression that the talk on their resume is more important then what you see with your own eyeballs.

(5) This is a high quality post, this was my thinking before forming the question. - Bryan Rowe
(4) Seconded. I'd vote this up twice if I could. - Electrons_Ahoy
(1) gasps for air - Dustin Getz
(1) With this so high on the page I may as well use it as a soap box: I think the FizzBuzz problem (the original one) should be even simpler then it is. Currently the candidate needs to make use of a modulus operator, and have been taught or figure out that comparing it to 0 will determine if two numbers divide evenly. While this could be done in psuedo code ("IF 5 DIVIDES EVENLY INTO x THEN") the candidate could think it was the trick. While I'd certainly prefer candidates that know something this elementary, it would only take 2 minutes to learn later. A true FizzBuzz failure would be hopeless. - David
(1) No, you don't need to use a modulus operator. If a person needs a modulus operator to tell if a number is divisible by another number, they have a problem with arithmetic, never mind programming. - Jeanne Pindar
[+33] [2009-10-28 15:22:56] Matthew Jones


It's a loop, simple math, and output. Should be no problem for entry-level programmers.

Math? What is "math"? An acronym for your first name?.. - Pavel Shved
(4) @Pavel - That's how they pronounce maths over here in North America. Maths = Math. I never understood it either. Mathematics is plural, so as far as I'm concerned, the abbreviated form should be too. - BenAlabaster
(4) In English, the noun mathematics takes singular verb forms. - zvolkov
(7) This from the same people who say "Manchester are winning"... - Michael Myers
(4) @BenAlabaster: "Mathematics is plural" Really? You would say "Mathematics are hard" rather than "Mathematics is hard"? - Beska
[+29] [2009-10-28 15:26:59] Tenner

Absolutely. HOWEVER, the interviewee may have legitimate performance anxiety that prevents them doing it in a fixed time on a whiteboard while an intimidating person (you) stares them down.

Make sure that the interview is "friendly" and that you give them time and space to construct a solution.

But if they can't put together pseudocode in an empty room with a pencil in a half hour, then they're not worth any more of your time. (Your criteria may vary.)

(4) I often wonder about the nervousness factor. It is pretty obvious when people get flustered, and I like to have them talk about the problem and what they are thinking -- instead of writing code. That way, you at least can get an idea of how their brain is approaching the problem. - Bryan Rowe
I've had killer interview assignments, FizzBuzz is nothing by comparison. The interviewee should be given at least 30 minutes alone in a room with no interruption. - Dave Swersky
(11) 30 minutes alone, for fizzbuzz? How about 10? And I'm not sure I'm sold on leaving them alone. I want to see how they solve a problem -- and hear them talk about it out loud. I definitely don't want to leave the room for thirty minutes to let them pull up an answer on their iphone. - Bryan Rowe
(1) @Bryan: How about asking the interviewee? Every person knows how they work best. I'd expect a potential employee to know this, so they can seek out the environment that makes them the most productive after they're hired. - Tenner
(8) That's why you allow detailed pseudocode. A person might mess up syntax under stress, but they should still remember logic. And 30 minutes is way too long. - Jeanne Pindar
(9) But - in the "real world" of coding, how often are we faced with hard deadlines that create intense pressure to finish? So the notion that the time limit creates false pressure in the interview is in fact the opposite - we want candidates that do not freeze under pressure. - Huntrods
@Huntrods: I agree; I guess it depends on the nature of your project. If the position is for an on-call developer to fix bugs in a live web app, time is of the essence. If the job involves working on a project with a twice-yearly release cycle, time isn't that critical. - Tenner
(1) @Tenner: Sorry mate but I disagree, tasks expand to fill the time allotted to them. All things being equal, if I have two candidates and one codes fizbuzz in 2 minutes, and one takes 30 minutes, I'm taking the guy who did it in 2 minutes. - Binary Worrier
(1) @Binary: Fair enough. I've never tried giving FizzBuzz in an interview though I'm sure I'd find that most candidates could complete it in 2 minutes, and those who took 30 minutes would likely not have it wholly correct anyhow. - Tenner
(1) Given the nature of FizzBuzz as an acid test against people who really can't program at all (and will waste lots of your time/money with excuses and run arounds), I think we can (and should) save the "can they work under pressure" for later on in the interview along with the harder questions. Often you won't receive a perfect candidate who gets everything right - at that point you'll be glad you didn't ask "all or nothing" questions, since you'll have the information needed to seperate the "can't program" candidates from the "can program and just need some on the job training" candidates. - David
(2) Come on! I'm all for trying to make an interview low pressure, and can understand if someone freezes up on some things...but if a candidate can't do FizzBuzz in his/her sleep, they're not worth spending time on. - Beska
Not to repeat myself, but I think FizzBuzz should be applied with a minimum of pressure. Much like debugging, we want to eliminate as many variables as possible - by the end of the interview I want to know if they can program (and thus deserve any consideration in the hiring process). In the "real world" management will demand that someone be hired after a number of interviews, even if your technical self didn't think any of the candidates where good (management views our kind as being too perfectionist). I can't be speculating if they failed the FizzBuzz question for other reasons. - David
As Scott Hanselman said, if your hiring singers, its not unreasonable to ask them to sing at the interview. if people can't cope with the pressure of an interview, what are they going to be like with a production issue and a short time to fix it? - Kev Hunter
[+20] [2009-10-28 15:23:43] Thomas Owens

Not only should a college graduate be able to answer the question, anyone who has taken one or two intro to programming classes should be able to answer it. It's not that difficult of a problem.

[+14] [2009-10-28 15:49:33] EMPraptor

Of course they should be able to do it provided they are not having a breakdown.

Maybe you could lead up to the problem with some exercise that shows you're not trying to embarrass them with a trick question though.

I remember being very nervous during an interview in which I kept being told that I gave wrong answers. Then I was asked write pseudocode that sorts elements that can be one of three colors. So I was wrecking my brain trying to out-think the exercise, thinking that none of the sorting algorithms I was remembering would be good enough for the guy. And I ended up not writing anything down.

Turns out he wanted me to count the number of elements of each color then populate the new array according to this.

So after the interview, I find a table and work out the answers to the questions he asked. Turns out, in all cases I was right. He had been judging interviewees against wrong answers to simple logic/math/CS problems. I intended to go back and inform him so he could do a better job (and to recover some of my dignity, I admit). But then I overheard him disparaging my university to his fellow interviewers, how he didn't encounter a single competent applicant. At which point I just turned around and walked away.

I guess I recall that account so you know to make sure the interviewer is not an incompetent asshole.

[+7] [2009-10-28 15:28:27] Dan

Any college graduate should be able to solve a problem as simple as FizzBuzz. Not being able to do so should raise some red flags.

(4) What if they majored in art history? - mgroves
(3) @Mgroves: Any college graduate (in any subject) should be able to handle the logic. The programming part, maybe not, but I tend to think that this question is not really about programmig. - Telemachus
[+7] [2009-10-28 15:26:18] the_mandrill

If you can't trust someone to be able to give a decent answer to a FizzBuzz style question then there's no way I'd trust them to be able to create something complex. Would you want them let loose on your large legacy codebase?

[+7] [2009-10-28 15:26:41] unwind

Considering the enormous exposure this interview aid has gotten lately, my first question to a failing interviewee would probably be "do you use the Internet much?"

Perhaps it's a good thing I don't do interviews.

And yes, of course a programmer should be able to solve this problem.

(9) Yes, whether a person a person recognizes FizzBuzz is a good indicator of whether they read blogs and forums, so recognizing it would be a plus. - Jeanne Pindar
(1) You can always change the problem to A BlahBlip problem with 4 and 7 as interval times. That will fool those remembering known problems. - Gamecat
[+7] [2009-10-28 17:41:05] JasDev

It seems like most competent programmers would be able to write the FizzBuzz solution even before stepping foot into a university for comp sci (since most dabble in programming during their high-school years). The comp sci curriculum is data structures, writing compilers, Big O notation, etc. The FizzBuzz is very easy in the sense that it omits virtually all the bread-n-butter compsci topics. The 4-year degree shouldn't even be a prerequisite! The FizzBuzz question is almost like asking if a college graduate should be able to add fractions.

[+6] [2009-10-28 17:09:49] temp2290

My degree is in EE, I took 1 CS class in my life, and I just wrote out a pseudocode answer to this in <1 minute. It's the equivalent of asking an EE grad how to analyze a simple circuit, or what an op-amp does... However, ask me about OOP concepts in an interview and I'm likely to throw a stapler at you.

What do CS courses teach if not problem solving within different contexts?

(1) Courses can teach all they like - read the other blog (CodingHorror) for some examination of the repeated attempts (and failures) of education to get over the "double bell curve" present in comp-sci. With the need to "produce" more and more graduates the solution has ultimately come down to passing students who don't really understand the material (the tests are adjusted until the student can get a pass just by reciting the text book or lecture, without understanding of what the words mean) - David
(4) Throwing staplers is not often a smart move during job interviews. But thanks for the warning, the next time I have to interview someone, I will wear a helmet. - Gamecat
[+6] [2009-10-28 16:39:51] Will Eddins

FizzBuzz is simple enough that I'd expect them to be able to write the solution not only in pseudo-code, but in the language of their choice, ignoring syntax errors of course.

I don't see why you should expect 30 minutes to come up with the following solution:

for(int i = 1; i <= 100; i++)
   string output = string.Empty;
   if (i % 3 == 0) output += "Fizz";
   if (i % 5 == 0) output += "Buzz";
   if (string.IsNullOrEmpty(output)) output += i;

Yes, I could have used StringBuilder to make string concatenation (as little as there is) slightly more efficient, or removed the concatenations by using if-elseifs instead. Hell, anyone who writes down string.IsNullOrEmpty should be hired right then and there.

Add: I'm nervous as hell during interviews, but I don't think I'd have trouble with a question as simple as this one. Typically, I've been asked either much harder questions that I've choked on, or been asked such unimportant questions, such as the syntax for operator overloading in C++, that any simple Google search would return the answer in a real-world situation. It's a touchy subject for me, knowing I have to rely on the quality of the interviewer.

While it might not be possible in many environments, I think the optimal situation would be to sit the interviewee on a computer with the newest version of Visual Studio up and running, and say "Write a function that answers the FizzBuzz question. I'd just like to see your coding style."

I feel like it'd be a situation like this where'd I'd really shine, just because I've learned to love the FxCop guidelines:

/// <summary> Prints the numbers 1 - 100, writing Fizz when divisible by 3, and Buzz when divisible by 5 </summary>
public void PrintFizzBuzz()
  for(int i = 1; i <= 100; i++)
    string output = string.Empty;
    if (i % 3 == 0) 
      output += "Fizz";

    if (i % 5 == 0)
      output += "Buzz";

    if (string.IsNullOrEmpty(output))
      output += i;


Yes, this is more work, but at least for me, it's much easier to visualize a solution with Visual Studio in front of me for such a trivial question than to write pseudo-code on a piece of paper. I do most of my work on a computer, not on paper, and I'm much more at-home in front of one. And doesn't this provide much more insight into the programmer's quality and their respect for readability?

(11) Ha! You prove my theory that FizzBuzz is a mind control program. Upon reading any mention of it, people are compelled to solve it. It is impossible to have a discussion about it without someone posting their solution. :-) - Jeanne Pindar
(1) Yup, I knew I'd be "the one" but it had to be done. Who says that someone here didn't still think this required a 30-minute solution? - Will Eddins
(3) Hate to say it, but the code is also slightly wrong. "Write a program that prints the numbers from 1 to 100" yours will print out 0-99. Ya, I know, minor quibble. - Fox Cutter
Wow... but then again, that's what I get for not testing :p Fixed. - Will Eddins
i % 3 is true when i is NOT divisible by 3, isn't it? - György Andrasek
(3) I also hate to say it, but your programs get every single 'Fizz' and 'Buzz' wrong. I think you want if (i%3 == 0) as the test for being divisible by 3, and similarly for the 5. :) - Scott Griffiths
lol... Fine, i screwed it up. - Will Eddins
(4) The revision history of this answer is pure gold :) - truppo
(1) So did you get the job? - Kirk Broadhurst
[+6] [2009-10-28 15:44:43] Farrell

FizzBuzz should definitely be able to be answered by a graduate - if they can't, then the course the took didn't teach them anything. I'd also be worried if they couldn't at least come up with a very simple answer to the question in a five minutes [never mind the 30 minutes that has been mentioned by others].

Aside from being able to answer it, you can also use it to determine other areas of an inerviewee's skill by simply asking them if they can improve it [and again after each subsequent improvement]. Then, once they reach the point that they say they can't, ask whether they're happy with it and/or why they can't improve it.
Improvements can include things like making it easy to add in a third term, not hard-coding in values, or other things that could be language dependent.

Remember to KISS, though. - mafutrct
[+5] [2009-10-28 16:10:58] Michael Brunton-Spall


Even if a junior programmer cant complete the FizzBuzz problem they should be able to sit with you, break down the problem to it's component parts (i.e. can I print Fizz for the multiples of 3 for the first 10 numbers, can I print Buzz, can I print both, what about 15) and explain how they would address them.

If the developer cannot break a problem down into it's simplest component parts then they will be useless as a developer.

If a developer can complete the FizzBuzz problem easily, worry more, ask them to break it down and see if they actually can do that, it's far more important than coding ability in a language.

[+5] [2009-10-28 16:12:22] quillbreaker

If they can't do FizzBuzz in a half an hour, then our programming test would make them weep. Of course, our test isn't intended to be finished within the alloted time by any but the best of programmers - what is important is how much you get done in the time allotted and what the quality of code is.

Do you also look at how they triage it (assuming this is allowed)? - Kurt
(4) What is your programming test? - tommym
@kurt I don't know what you mean by triage. - quillbreaker
@etlerant Essentially, you're given a small relational database and are asked to write some very specific functionality around it. The premise around the problem is that there used to be a piece of software that talked to this database, but it has been lost, and some limited functionality is needed soon to continue operations on monday. There's a display web page, an insert web page, a web service, and a tricky SQL query to write. 4 hours is given. I finished all 4 problems in 4 hours, but then again I wrote the test. grin - quillbreaker
(2) Holy smokes, a 4 hour test! - tster
We got burned really, really bad by hiring someone who couldn't code thier way out of a damp paper bag. They ended up on a one man project with limited visibility so we didn't have a clue that they were making no progress... so six months of pay, and no (usable) results. If the economy were better, I'd never suggest a 4 hour test, but as things are, you can get away with it. - quillbreaker
[+5] [2009-10-29 15:22:07] Alan

The question isn't as simple as it may sound. Not every good programmer may like puzzles and not every good programmer can focus enough in an interview setting to see that it's a simple modulo question -- even more so if they don't have to deal with the modulo operator much in their field. From what I hear, a CS grad in the US should easily recognise the problem and be able to solve it. From my personal experience in my country, this doesn't hold true universally -- the modulo operator is a bit obscure if you're not actually dealing with pure algorithm design much.

If you test someone on how well they perform in solving well-known puzzles, you are only testing them on exactly that. This may be a good indicator of whether they are of any use, but the importance may also heavily depend on the programming tasks you're looking to be solved in real projects -- a maths nut may not be the best choice for GUI programming and a GUI programmer may not be the best choice for writing a physics simulation.

If the interviewee is completely clueless and can't solve the problem even after being given straightforward hints, they still might simply be too nervous, but chances are that they will perform equally badly under real stress or simply not know much at all.

It's certainly a good clue, but it's not fail-safe enough to rely on it alone. Variable naming and such can be telling, as can be the actual process -- let them use a realistic environment if you want insight into their actual abilities (can they tell by their code and its output what they are doing wrong? can they fix it? is the result patchy or clumsy, or did they actually improve it?). Looking at the code and asking them about it may also help to judge not only whether they are good, but also whether they can communicate their thoughts and what they did (is the code readable? can they explain how it works?).

Don't ask them to describe it as they do it -- that's distracting (writing code is a linguistic process, talking may interfer with it) and may hamper their creative process. But if they can't justify what they do or can't describe the function in layman's terms (not idiot-proof, but other-people-proof), they may be difficult to work with in a team or leave a mess behind when they leave you for new shores.

If they can't solve FizzBuzz, try another question. Maybe try a different topic, or something easier. If they can't even write a loop over an array, that's a good indicator they're lying about their skills. Also test them one things they claim to be good at. Don't insist on code samples if they can't write you any in the interview, but test their abstraction skills (e.g. ask them for the way they would do something in general terms, then ask them for something on a lower level, try them on several layers, not just one).

For good measure, here's my take on FizzBuzz in Python (without looking at samples and after forgetting to output non-fizzbuzz numbers literally):

def fizzBuzz(n):
    l = []
    for i in range(1,n+1):
        fizz = (i % 3 == 0)
        buzz = (i % 5 == 0)
        if fizz:
            if buzz:
                l += ['FizzBuzz']
                l += ['Fizz']
        elif buzz:
            l += ['Buzz']
            l += [str(i)]
    return l

(1) Interesting to have another perspective - I agree, it depends on the definition of the 'programmer' role. A GUI designer may not need exception procedural logic; not a DBA for that matter. However, I would be very concerned about anyone who can't at least write a pseudocode solution. Even if the job was completely non-technical I would still expect the applicant to be able to satsify FizzBuzz in some logical explanation (I wouldn't test them, but I would be very concerned if they couldn't complete it). Can you imagine having to explain something to someone who can't understand FizzBuzz? - Kirk Broadhurst
(1) If you take pseudo code to allow something like "if isMultipleOf(5, x)", I agree. The modulo operator can appear to be a bit obscure unless you happen to be doing a lot of arithmetics. - Alan
[+4] [2009-10-28 19:20:00] 4.669201

I think the question has a subtle trick to it. The straight forward solution is obvious (checking for each condition), but there's a hint that there's a really cool one line solution when you noticed that mod 15, is FizzBizz, the concatenation of the two strings for mod 3 & mod 5. Perhaps I read too much Perl.

(1) Except that one-liners are a terrible PITA to work with in real projects because they are rarely self-documenting. If you want a perl hacker, sure, but don't expect to get any reusability (in the sense of "usable by anybody other than the perl hacker who wrote it, when he wrote it") out of it. - Alan
(2) I don't see how that's a cool solution. They are independent evaluations so it makes sense to split them into two evaluations. Keep it simple and maintainable. - Kirk Broadhurst
[+3] [2009-10-28 20:03:23] Josh Leitzel


Out of curiosity, I just tried this question.

for (int i = 1; i <= 100; i++)
    if (i % 3 == 0 && i % 5 == 0)
    else if (i % 3 == 0)
    else if (i % 5 == 0)

This took me less than 4 minutes to think/write.

I am a college student whose first programming class was last semester.

So yes, I think someone who has a CS degree should be able to do this.

I agree! It took Eclipse longer to open than it took me to write the code. I am in my 3rd semester so I have a little bit more knowledge, but anyone who has finished their first programming class should be able to do this! - Josh Curren
I think this is one of the cases where you're actually more likely to solve it (quickly) the less experience you have. If you're in the second or third semester and can solve it already, it's obviously not a good test to determine a programmer's worth. In many fields you actually have to use low-level arithmetics a lot less the more you know about the field at hand (abstraction, etc). Not saying either of you is a bad coder, just saying you being able to solve it doesn't mean everybody who can't solve it knows less than a freshman. - Alan
[+3] [2009-10-28 23:05:00] György Andrasek

FizzBuzz? Give them one of the first twenty Project Euler [1] problems and ask them to think out loud as they try to solve it. That should prove once and for all if they're capable of problem solving and/or algorithmic thinking.

Of course they won't solve it without a computer, but at least they should be able to tell you how they would approach the problem.


Right, but before you even want to get into a complicated discussion you want to know if it is worth the interviewer's time. - Bryan Rowe
(3) I disagree. Talking while writing code is unusual for anyone outside of a teaching context -- and then it's usually code they've written before. As most good programmers already have enough problems with normal social interaction, you can expect them to get even more nervous when asked to talk while writing in an interview. Ask them to tell you what they intend to do or did, but leave them free to just jot down code when they have to. They have to be able to communicate, yes, but not in the act. You want a coder, not a synchronous translator. - Alan
That's is also a good interview question. While FizzBuzz is a waste of everyone's time if they are competent, it is good for culling out the pretenders in a room full of applicants. - Kirk Broadhurst
[+3] [2009-10-29 14:47:11] ElGringoGrande

Depends on what you want for an answer. Would the following suffice?

for every integer going from 0 to 100
  if thenumberismultipleof(3) then print fizz
  if thenumberismultipleof(5) then print buzz
  if thenumberismultipleof(3) and thenumberismultipleof(5) then print fizzbuzz

I haven't used the modulus operator in over five years because of the type of software I write. I have no use for it. The only thing I need is to know at times is if a number is even or odd. I have written an extension to do that (used to be in a utility component).

Why? Because reading

If (score.IsEven) {...}

is much more clear than reading

If (score % 2 = 0) {...}

Plus i don't have to worry about "2" accidently gets turned itn "22".

So using the modulus operator, and many other "basic" operators/framework methods, is not in my work routine. In fact I do very little math/number work. That work was done years ago and resides in various components and works so well I don't ever have to revisit it. Why should I be able to spit out the use of these things during an interview? Why should I expect others to do this?

In the end the fizzbuzz test is a trick to help people that do not know how to interview. They don't know how to judge the competence level of strangers. It is understandable because those are very hard skills to acquire. They might even be magical power for all I know.

So I think that if that is your primary trick, or if it is used as a show stopper, you are going to miss out on some good hires. Especially if you are going after young kids right out of college.

(1) Check your logic: you need to put the third test first, or you will never see "Fizzbuzz". (Also, go from 1 to 100, or off-by-one. Finally, I'm assuming you really mean if...else if...else in the condition.) - Telemachus
(5) If there's one thing I learned from the I/O Psychology class I had to take, it's that almost everybody thinks that they can interview and judge character, but almost nobody actually can. That's why performance based test like this one are not only a good idea, but are also legally preferable. - Shea Daniels
@Shea One thing I learned from my psychology degree is that with proper training and experience people can become good a interviewer. There are techniques that can even be learned by the average Joe. - ElGringoGrande
@Telemachus Hehe. Of course you are technically correct but would errors like that actually affect your decision to hire a person? Wouldn't mine. The gist is there. - ElGringoGrande
+1 for the pseudocode - of course it is acceptable, that's exactly how the pseudocode should look. If I want to know how thenumberismultipleof function works I'll ask. -1 for the interview rant. Talking the talk is different than walking the walk. Many people know all the buzz words, are very confident and can talk their way out of a hostage negotiation. I have no doubt they'd beat the lie detector test if asked 'are you a great programmer' because they genuinely believe it. Unless you ask them specific technical details you can't test whether they are the real deal. - Kirk Broadhurst
[+2] [2009-10-30 20:51:35] Spanky

We hire people to do a specific job. I need a web service that can do x. I need a game engine that can do these things...

Does Fizz Buzz come under that job description? Does Linked List?

I mention this because of some of the comments noted above. There are many opinions about what a computer science grad should be able to do and that if they can't they aren't qualified.

There are many questions which could stump even seasoned programmers. Are they not qualified?

Well, maybe yes and maybe no. The thing is what am I hiring them for? To handle generic questions in tech they might not know that they haven't seen before under pressure, or to do a specific task that they can figure out and implement in a reasonable amount of time?

Once we prescreen the candidate, really see that he can do the tasks at hand, or figure them out on the job, we bring him in. Not before. Having trouble prescreening? There are ways to solve that easily and without extra manpower.

I'd rather send a guy a code screen, or have him come in to do one onsite. Give him access to the tools he will use on our job, and then let him have at it Google and all within the time frame that I would need this done from a junior team member.

That's a fair test, and a less demoralizing process for both he and I.

[+2] [2009-10-30 21:03:25] z5h

We had a very "senior" level contractor come in to look into something for us, and as part of a screening process, administered a similar type of question. He refused to answer saying it was below him.

As part of the interview discussion he told us the way we wanted to do something was "impossible" and would never work, and that we should hire him and do things his way.

We didn't hire him. We did things our way. The "impossible" worked just fine.

Never mind the level of person you're interviewing. The question is simply: can they pass this test?

A lot of people are very good at talking the talk but not walking the walk. Ideal for a contractor, because they simply appease management for a short term and move on. Things got 'shaken up' and management are happy. Repeat. - Kirk Broadhurst
[+2] [2009-11-01 15:57:02] user200523

Absolutely. As with any interviewing technique, it should be used to filter out the people who obviously have no idea what they are talking about and you don't want to spend too much time with. That is, it should be used a negative filter. If you can't solve it well in under five minutes, no hire. Actually, it would be a great phone-screen question. Easy to ask and a solution is easy to describe over the phone.

I wish interviewers were more about asking questions like this that let you show off the goods and less about what keywords you have or don't have on your resume, whether you include a separate cover letter with your email and resume and address the recruiter by name, or whether you have correctly prepared answers to the typical questions like "what is your greatest weakness"... etc.

And no, you don't need to know the modulus operator to solve it. - user200523
[+2] [2009-10-28 17:39:29] Ravi Wallau

Yes! You either can do stuff like that in the beginning of your career or you will never be able to.

We started doing a programming task for new hires in my company. The quality of the tests, even for senior developers, is behind what we are expecting, and I am glad we have this test in place now.

[+1] [2009-10-28 17:34:09] Tchalvak

I think that FizzBuzz is a fine "logical" problem, but you'll really want to couple it with a separate problem that actually applies to the code that you work on every day.

I know for my latest interview, I did up some test code on recursive json, and gave a code sample of my own work, but when it came to the actual job, debugging in the large codebase that exists is the hardest part.

I often wonder whether that test was meaningful since it was so far off of the mark of the day-to-day stuff that I do.

[+1] [2009-10-29 16:40:56] Gergely Orosz


Surprisingly a lot of candiadates aren't even expecting this kind of question so apart from the fact that it gives you some information on wether the candidate can code it also shows you how he handles unexpected situations.

[+1] [2009-10-28 22:33:58] Anthony

I wish I had a interview where they asked me fizzbuzz. I am a cs student and I could answer that question even if I had a total brain meltdown.

The only time I would not not ask it is if they came in with some code from a program that solved some real world problem. At that point fizzbuzz is not needed

[+1] [2009-10-28 18:01:14] akf

Not only is this a good test to see if the candidate can think in (pseudo) code, a simple test like this can be used to:

  • highlight the candidate's thought/design process (especially for more junior, or interview-shy candidates)
  • serve as a springboard for further discussion

[+1] [2009-10-28 18:09:52] community_owned

Any computer science student should be able to answer these sorts of questions. But twe things occur to me. First, keep in mind that nervous people often appear dimmer than they are. In particular, I've seen people thrown off (even offended) by how simple a question is. It's probably worth giving them a couple tries on different questions so that you can get an accurate picture of what they are capable. Second, as many have pointed out this is a very common problem; as such you may not have the luxury to dismiss them all. Instead, I believe it's also worth exploring higher-lever problem solving skills. You may find that they still have something to offer or that they can more easily answer the simple questions after having some success with more challenging questions. I'm not saying it's okay for "programmers" to be incapable of solving FizzBuzz problems, but I think it's worth making a concerted effort to understand someone true capacity before discounting them.

[+1] [2009-10-31 15:16:05] Tim Post

Its dangerous to taste a meal by sampling a few things on the table. I met some of the most clumsy developers that I know five years ago .. trained mostly by Google after a pathetic CS curriculum at some way too expensive university failed to equip them to actually get a job. Most of them are now brilliant.

When I hire, its for one of two reasons:

  • This person really, really knows what they are doing, is patient and can bring up the over-all quality of the team
  • This person has some skill and a burning desire to pick the brains of their peers.

Of course, placement matters. A recent Wikiversity graduate is not going to take on a lot of responsibility during their first few months.

When I say "Don't call us, we'll call you", its because:

  • The person who can't solve a simple problem projects an "I know everything and I destroy bad code in my spare time!" image
  • The person is sharp, but not well enough exposed to our language of choice for the project that will receive them (learning curve is just too steep)
  • I saw the person acting in a really, really funny porno .. and just can't conceivably take them seriously after that, much less contain my laughter during the interview.

NB: the third case actually happened, which is why I noted it.

Btw, the solution (in C)

#include <stdio.h>
#define TOP_AND_BOTTOM printf("+-----+------+------+\n");
#error "How much time are you going to spend on a stupid interview question?"
int main(void)
  unsigned int i;
  for(i=1 ; i < 101 ; i++)
    printf("| %-3d | %-4s | %-4s |\n", i, i%3 ? "" : "Fizz", i%5 ? "" : "Buzz");
  return 0;

.. Could be a little more optimized, but I was making a point. I probably should not put the whole formatting task on printf(), its notoriously slow.

Could you get into legal hot water for the third reason? - Andrew Grimm
[0] [2009-10-31 16:18:47] Sergio Tapia

I was honestly a bit terrified about what the question was going to be (First time I've ever heard of the FizzBuzz name). After reading it though, I know for a fact I solve this in 25 seconds. Can people honestly, not do this? :S

[0] [2009-10-28 17:47:00] Chad

Non programmers should be able to do this after reading ANY intro to programming textbook's first few chapters.

[0] [2009-10-31 14:49:15] blwy10

I taught myself programming, and I wrote it in C++ in under 2 minutes. I'd say give them something harder, like write a program to list out all the primes from 1 to 1000000. Even then, that's still quite easy.

Questions I definitely wouldn't give them though, considering they're entry level staff, are IOI [1] tasks.


That's great, but most com-sci graduates didn't teach themselves anything. You aren't average. - Kirk Broadhurst
(1) I disagree; much of what you have to learn in university will involve some element of self-teaching, and besides Fizzbuzz can be composed by anyone using rudimentary knowledge. If a graduate fails to do this, then it means his university or college didn't do enough to prepare him. - blwy10
[0] [2009-11-16 22:48:02] Aksel

I suspect those failing to answer were baffled by the stupidity of the task. They probably wasted their time trying to figure out where you hid the camera.

[0] [2009-12-02 22:50:26] Pavel Reich

The question is fine as a starting point for discussions about how to solve it shorter/better/etc. btw, is there any shorter version in perl? I can write it only in 94 chars (yes, with spaces to make it more clear)

print join("\n", map ( ($_%3 == 0 ? "Fizz" : "") . ($_%5==0 ? "Buzz" : "") || $_, 1 .. 100));

[0] [2010-04-12 03:12:48] MusiGenesis

Unfortunately, higher education is a business like anything else. If I were a cynic, I might think that the abundance of CS-degreed programmers who couldn't write Hello World in Visual Basic with a gun to their heads is in some way related to the need of CS departments to keep their enrollments up.

Because when you look at it that way, you start to see these departments as degree mills that suck in the country rubes, pocket their tuition dollars, and send them on their way without ever disturbing their self-delusions of grandeur. And I'd be angry if this weren't so true of (U.S.) higher education in general.

So yes, entry level programmers should be able to answer FizzBuzz. They're certainly paying enough for the privilege.

[0] [2010-07-22 11:32:13] Anthony Pace

I gave myself 5min, and I wrote two ways of doing in paint using my wacom tablet...just to get the feel for actually writing it out...if you can't code this you really shouldn't be coding professionally, and it is really hard to believe someone claiming to have experience, that actually made it to the in person interview couldn't do this.

I used AS3 and although not terribly original, it is by me, Anthony Pace

    //there was of course the obvious...
    for(var n:int=1; n!=100001; ++n){
        }else if(n%5==0){

    /*but it seems like the fastest  variation (in my mind at least)
I could come up with in under 5 min was one that uses a variable outside*/
        var output:String;
        for(var n:int=1; n!=101; ++n){
            }else if(n%5==0){
        // you could also trace output.substr(0,output.length-1); to get rid of the extra linebreak if it is absolutely neccessary

[0] [2009-10-28 16:44:17] DucDigital

Man, this is pain... anyone have proper study of comsci should know how to do this at least.... :(

I suggest you keep using this kind of test :)

[0] [2009-10-28 16:52:17] Jeff O

I wouldn't determine hiring based on a right or wrong answer. You hope this would be an exercise in how the person thinks/programs.

You wouldn't be able to answer FizzBuzz? That's a brave admission. - Kirk Broadhurst
The question had nothing to do with whether I could answer FizzBuzz. - Jeff O
[-1] [2009-10-28 17:44:43] WayneM

Going to play Devil's Advocate here and say "no". Being able to answer trivial programming questions doesn't mean that you can program, and I find it painfully annoying when I interview and get asked basic nonsense despite having programming experience. Ask me about real world problems, not textbook crap. It's as bad as asking somebody to write a program to sort numbers.

Many programmers are self-taught and have no idea what this FizzBuzz stuff is, but they can write applications that work. That should be the only thing that matters, not being able to regurgitate theoretical nonsense learned in college. CS courses don't do squat to prepare you to develop real world applications.

Even though I disagree, I'd love to see more people argue no, just to get some new points. I do agree with the fact that asking someone 'What does function X in the .NET framework do?' is worthless and stupid. Why would anyone care if someone has memorized the language spec? - Bryan Rowe
(14) "Many programmers are self-taught and have no idea what this FizzBuzz stuff is, but they can write applications that work." What kind of useful application could they possibly write that is more simple than FizzBuzz? You're not thinking that the person is being asked to "Write FizzBuzz" without being told what it is, are you? - Beska
(6) And how is FizzBuzz theoretical nonsense? It's just a simple application, with very clear parameters. If they can't write FizzBuzz, there is simply no hope that they will be able to write anything of value. - Beska
What I mean is you can write real-world, working programs (not trivial stuff) without being able to write textbook CompSci problems. Asking a trivial question isn't a good way to gauge somebody's competence, IMO. - WayneM
(4) The goal of FizzBuzz is not to be a text book problem (in fact it subtlety avoids being one unless you took programming 25 years ago), since those kinds of problems are open to regurigation answers. Remember, you're not trying to see if the applicant can solve problems (that's for later in the interview), you're determining if they can talk to a computer at all. FizzBuzz is so trivial because it's meant to pose no problem solving challenge at all. - David
(4) @David: exactly so. It's essentially a preface to the interview, to see if the person is worth actually speaking to at all. If they do it easily, great...2 minutes gone. If they can't do it, there's no sense in spending any further effort. - Beska
(11) "Being able to answer trivial programming questions doesn't mean that you can program." No, but NOT being able to answer this means you CAN'T program. Which means there's no point wasting time asking you to solve real world problems, which - surprise - do involve looping sometimes. If you answer it in 2 minutes, try this real-world problem. - Nathan Long
(1) +1 for the discussion - Drew
I've been amazed at the trivial stuff I've been asked to do on interviews, but I figure it's part of the company's process. Besides, that stuff doesn't take long (the longest part of one question was making sure they didn't want more than a simple SQL SELECT statement). - David Thornley
(1) @David Thornley: yep...sometimes overly simple questions can look like trick questions...I try to get a feel for what the candidate is thinking and if they look like they're wondering what the catch is, then I just reassure them that it's supposed to be as simple as they are thinking. - Beska
+1 just cuz. If these idiots can't figure out, without fizzbuzz, that the fizzbuzz failer can't code, then they shouldn't be hiring. - Ewan Todd
(2) If anyone cannot answer this question they should never have an IDE open or have commit access to your SCM system. The amount of copy pasta garbage that they would put would take for more effort to clean up. This is essentially a low pass filter. There are PLENTY of people that can bullshit their way their life regurgitating things they were taught without being able to understand anything in depth. Talking about high level problems leave you open to the BS interview attack. - Min
(1) Thinking? Thiiiinking? We don't need no stinking thiiinking around here, we do WORK in these here parts! - Paul Nathan
These kinds of questions do little to test my ability to do the job at hand. What am I being hired to do? Fizz Buzz or a specific task that will ship? I know the answers needed to ship the code, I may or may not know the one needed to solve the not advertised in the job description one you pull out of a hat on code screen day. There are many code screen questions out there after all. But what I applied for, well I was qualified for that or wouldn't bother right? And Fizz Buzz, that doesn't determine whether I can write a web service for example. - Spanky
(1) FizzBuzz is a programming question, not the programming question. A correct answer might not tell you much, but an incorrect answer certainly does. I don't think anyone is suggesting that the entire interview consists of FizzBuzz. - t_scho
I've also had people who can't write a for loop in an interview, one really wonders how they got their degree. - Anders K.
[-1] [2009-10-29 15:41:42] Damian

You are essentially testing for knowledge of the % (modulus) operator, or equivalent - not something we often use. I know of it from 8 bit programming days - not sure if I've used it more than a couple of times since then.

I know I'll be downvoted, but nevertheless, no, it isn't a good question.

(3) Not really. You definitely don't have to use mod. - Bryan Rowe
(1) example: double x = someNumber / 3; if(x == (int) x) //this number is divisible by 3 You could also use Math.Floor and other built in functions obviously - Bryan Rowe
(2) -1 It even says pseudocode in the question. (ifnumberisdivisibleby3) print Fizz, else (ifnumberisdivisibleby5) print Buzz, etc. - Kirk Broadhurst
@Kirk Broadhurst: I think you meant s/else/if , otherwise how can it print both fizz and buzz? It would work great till you hit 15 ;) - Tim Post