Skip to content

Instantly share code, notes, and snippets.

@profesor79
Created March 22, 2023 13:08
Show Gist options
  • Save profesor79/13b62b8e6aa8d965299edecbc691fc58 to your computer and use it in GitHub Desktop.
Save profesor79/13b62b8e6aa8d965299edecbc691fc58 to your computer and use it in GitHub Desktop.
public void DoFizzBuzz()
{
var combinations = new Tuple<int, string>[]
{
new Tuple<int, string> (3, "Fizz"),
new Tuple<int, string> (5, "Buzz"),
};
for (int i = 1; i <= 100; ++i)
{
bool found = false;
foreach (var comb in combinations)
{
if (i % comb.Item1 == 0)
{
found = true;
Console.Write(comb.Item2);
}
}
if (!found)
{
Console.Write(i);
}
Console.Write(Environment.NewLine);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment