Skip to content

Instantly share code, notes, and snippets.

@Plus1XP
Created March 13, 2018 02:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Plus1XP/ea7abcf40071fbbe8c62c78d56515fbd to your computer and use it in GitHub Desktop.
Save Plus1XP/ea7abcf40071fbbe8c62c78d56515fbd to your computer and use it in GitHub Desktop.
Fizz Buzz using Bools
public void DoFizzBuzz()
{
for (int i = 1; i <= 100; i++)
{
bool fizz = i % 3 == 0;
bool buzz = i % 5 == 0;
if (fizz && buzz)
Console.WriteLine ("FizzBuzz");
else if (fizz)
Console.WriteLine ("Fizz");
else if (buzz)
Console.WriteLine ("Buzz");
else
Console.WriteLine (i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment