Skip to content

Instantly share code, notes, and snippets.

@jonny-novikov
Created May 7, 2023 10:08
Show Gist options
  • Save jonny-novikov/33461bddec266f9b830a12668eda553d to your computer and use it in GitHub Desktop.
Save jonny-novikov/33461bddec266f9b830a12668eda553d to your computer and use it in GitHub Desktop.
FizzBuzz Problem solution in modern C#
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