FizzBuzz Test!

I recently came across the concept of a “Fizzbuzz test”. Having never heard of it,  I have of course done a little bit of googling on it. It’s not a test to see if you’re a malfunctioning robot like you might imagine, instead the concept is that too many people going for programming jobs, don’t in fact know how to program. The idea is to have a very simple program which candidates are asked to write out, on paper to see if they are able to think of a solution to a basic, but nonsensical and useless requirement. This helps weed out candidates that go for programmer roles, at the very start of interviews, that are unfit for the task. I have been told that it works and catches some people out, and other reports on the interwebz report the same.

Anyway, this is the requirement.

“Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.”

Sounds stupid huh?

But not that hard for us code monkeys.

I whacked out the following as a javascript example.

for (var i = 1; i <= 100; i++){
    if (i%3 == 0 && i%5==0){
        document.write ("fizzbuzz!</br>");
    else if (i%3 == 0){
        document.write ("fizz!</br>");
    else if (i%5==0){
        document.write ("buzz!</br>");
    else {
        document.write (i+"</br>");

It seems to work.

PHP, being quite similar in syntax to Javascript in a lot of ways, can be done as follows.

for ($a = 1; $a <= 100; $a++){
    if ($a % 5 == 0 && $a % 3 == 0){
        echo "Fizzbuzz!</br>";
    else if ($a % 5 == 0){
        echo "Buzz!</br>";
    else if ($a % 3 == 0){
        echo "Fizz!</br>";
        echo $a."</br>";

The idea is that you can use any language you are comfortable with, and it doesn’t actually get compiled to make sure you get everything absolutely syntactically correct, but it shows someone with a programming mind, that you think similar and can take on challenges.

You can check out the results of both here.

I think the concept is solid. I’ve had to deal with people before that claim to be programmers and couldn’t complete this test, let alone the task given to them. I am likely to use the concept however I think when I do I will think of my own little problem rather than use the existing one, just in case someone stumbles across a page such as this before their interview.