-
-
Save profesor79/13b62b8e6aa8d965299edecbc691fc58 to your computer and use it in GitHub Desktop.
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
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