Created
March 13, 2018 02:24
-
-
Save Plus1XP/ea7abcf40071fbbe8c62c78d56515fbd to your computer and use it in GitHub Desktop.
Fizz Buzz using Bools
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() | |
{ | |
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