The FizzBuzz Test

Recently I watched this amazing video from a YouTuber I would really recommend:

The Problem stated in the video describes a simple children´s game called FizzBuzz and goes like this: Two persons count up alternating while replacing numbers divisible by 3 with “Fizz”, all numbers divisible by 5 with “Buzz” and if divisible by both with “FizzBuzz”.
So far so good. For computers this problem is easy to solve but hard to master. In the field of programing you can choose from different approaches that will lead to some solution of the given problem.

Some may can relate the style of coding to his or her work philosophy. Is the code redundant or inflexible for the sake of getting the solution done quickly? Or is more complexity giving the code a more solid fix for the problems that might come up later?

Here you can see my try on the FizzBuzz game in Java:

The output of the program line 1 to 20 looks something like this:

FizzBuzz
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz

So what I´ve learned from my blind try.
The method I used is called a if-else-ladder. Nevertheless I could have shortened line 8 to a simple i % 15 == 0. This would make things easier if you want to change the rules of the game later; e.g. you only have to edit three bits of code if you want to change the numbers.
I learned a lot about my coding style and skill by letting my guide by intuition and speed. For this I also compared myself to the different approaches of others.

The use of an array makes up a short and one of the most interesting solutions:

Another solid and, how i think, experienced solution is the recursive one:

Both of the code samples were found on this nice site called rosettacode.org.
What you as maybe a person who isn´t into coding can learn from this for life is the fact that there are always many ways to victory. All solutions including mine are viable and at least outputs the game according to the given rules. We all have to make decisions and work out ways to handle with our problems and as long as you find your way and can learn and reflect on it, everything is fine.
Thank you for reading!

Further interesting readings and sources:
Blog Post – Using FizzBuzz to Find Developers who Grok Coding
Collection of Java solutions – FizzBuzz/Java