FizzBuzz : an Introduction

Mohammad Khan
3 min readAug 9, 2018

--

FizzBuzz is a problem solving puzzle for programmers that has been the topic of many online board discussions. If you read r/cscareerquestions/ or read tech blogs you have probably come across it in some form. What is the reason some people love giving it, and others hate being asked for it? What does FizzBuzz actually entail? Read on for more answers

The FizzBuzz problem

The basic problem is:

  • Print 1–100, each on a new line
  • For a multiple of 3, print “Fizz” instead of the number
  • For a multiple of 5, print “Buzz” instead of the number
  • For a multiple of both 3 and 5, print “FizzBuzz” instead of the number

Solution in JavaScript

Here is a repl link in case you wanted to play with it

What is FizzBuzz used for?

FizzBuzz is often given to programmer applicants as one of their hurdles to solve. Having just done the problem, you may think, what is the big deal? Here are some reasons why it’s given

Most good programmers should be able to write out on paper a program which does this in a under a couple of minutes. Want to know something scary? The majority of comp sci graduates can’t. I’ve also seen self-proclaimed senior programmers take more than 10–15 minutes to write a solution.[1]

What I’ve seen is interesting at least. People didn’t know the modulo operator, so they wrote ”modulo” — OK. People didn’t know about modulo at all, so they used Math.floor(number/3) — unexpected, creative, but a valid solution. People tried to be smart concatenating strings, but missing the space in-between — bad. People used nested ifs, ending in code not working, while claiming themselves senior with 15 years experience — very bad.[2]

Even if you CAN easily solve it, but you give me huge static about being asked to do such a menial task will count against you. Being on a team means having to sometimes do things you might not enjoy but are necessary. If right off the bat, before we’ve even started to work together you think it would be best to try and assert your special status of being above doing something I’ve asked you to do then it will act as a mark against you.[3]

The last quote really makes sense. In a job, or even your own projects, you will have to do menial and tedious tasks because … they have to be done. We have all worked with someone who didn’t want to do something because they think they are too good to do it. But the greatest people I have ever worked with would not hesitate to do the most menial tasks. If you are new to programming, I hope you learned how to do FizzBuzz. If you are well experienced, I hope you learned that when asked to do FizzBuzz, do it with a smile.

--

--