As the Sample Programs in Every Language collection grows, I’ve been compelled to add another project to the series: Fizz Buzz in Every Language.
Table of Contents
What is Fizz Buzz?
For first timers, Fizz Buzz might sound like a children’s cartoon. In reality, it’s a program that has plagued developers in interviews for ages. In fact, there have been countless articles written on the subject:
- Fizz Buzz Test by C2 Wiki
- Fizz Buzz by Wikipedia
- Why Can’t Programmers.. Program? by Coding Horror
- FizzBuzz In Too Much Detail by Tom Dalling
So, what is Fizz Buzz? Well, for the purposes of the Sample Programs repo, I’ve defined the rules as follows:
Write a program that prints the numbers 1 to 100. However, for multiples of three, print “Fizz” instead of the number. Meanwhile, for multiples of five, print “Buzz” instead of the number. For numbers which are multiples of both three and five, print “FizzBuzz”.
In other words, a Fizz Buzz program should have the following output:
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz ... 97 98 Fizz Buzz
If that seems simple enough, why not take a crack at it in one of your favorite languages? We can always use the help! Otherwise, feel free to peruse this series.
Why Fizz Buzz in Every Language?
After creating the Hello World and Reverse a String series, I wanted to expand the collection even more. Unfortunately, I was never sure which direction to take the collection, so I looked for a list of ubiquitous programs. In other words, I wanted to find a set of programs that people commonly want to know how to write. Unfortunately, Google didn’t turn up many results, so I guess that’s a writing opportunity for me.
However, in my searches, I did find two other program collections:
Of course, Fizz Buzz is much easier than 99 Bottles of Beer, so I decided to start with that. Perhaps in the future, we can add 99 Bottle of Beer to the collection.
An Alphabetical List of Languages
As usual, here’s a list of articles organized alphabetically:
As always, thanks for sticking around. If there’s a language missing that you want to see, feel free to drop it down in the comments. I’m always looking to explore new languages.
Also, don’t forget to subscribe, so you can keep up with the latest articles.
Recently, I was giving a lecture about Java's "common" methods (i.e., all of the methods of Object), and I had epiphany about how Java only has toString() while Python has str() and repr(). So, it...
Magic numbers are numerical constants that have no clear meaning in the code and therefore make code harder to read. Anything that makes code harder to read is something we can use to obfuscate our...