Last active
December 19, 2015 11:49
-
-
Save JeremyMorgan/5950968 to your computer and use it in GitHub Desktop.
FizzBuzz Problem in command line C#
This file contains hidden or 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
using System; | |
using System.Text; | |
class FizzBuzz | |
{ | |
static void Main() | |
{ | |
for (int i = 1; i < 100; i++) | |
{ | |
if ((i % 3 == 0) || (i % 5 == 0)) | |
{ | |
if ((i % 3 == 0) && (i % 5 == 0)) | |
{ | |
Console.WriteLine("FizzBuzz"); | |
} | |
else if ((i % 3 == 0) && (i % 5 != 0)) | |
{ | |
Console.WriteLine("Fizz"); | |
} | |
else if ((i % 3 != 0) && (i % 5 == 0)) | |
{ | |
Console.WriteLine("Buzz"); | |
} | |
} | |
else | |
{ | |
Console.WriteLine(i.ToString()); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment