Monday, January 12, 2015

Fizz Buzz (C#)

Fizz Buzz Puzzle
"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”."

This is my take on the "Fizz Buzz" puzzle. I stored it in a Dictionary so it is re-useable, but it just as easily could have been a simple Console.WriteLine(); format. I made the index of the Dictionary the int 1-100 so it could be manipulated and stored the answers to the fizz buzz as strings. I saw some neat one-line solutions with chaining if/else statements and using LINQ! It's fun how there are many ways to solve the same problem! I like how this is simple to read and logical.

And, of course the actual program calling this..