Created
May 7, 2023 10:08
-
-
Save jonny-novikov/33461bddec266f9b830a12668eda553d to your computer and use it in GitHub Desktop.
FizzBuzz Problem solution in modern C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
foreach(var i in Enumerable.Range(1, 100)) { | |
var output = (i % 3, i % 5) switch | |
{ | |
(0, 0) => "FizzBuzz", | |
(0, _) => "Fizz", | |
(_, 0) => "Buzz", | |
(_, _) => i.ToString() | |
}; | |
Console.WriteLine(output); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment