Skip to content

Instantly share code, notes, and snippets.

@JeremyMorgan
Last active December 19, 2015 11:49
Show Gist options
  • Save JeremyMorgan/5950968 to your computer and use it in GitHub Desktop.
Save JeremyMorgan/5950968 to your computer and use it in GitHub Desktop.
FizzBuzz Problem in command line C#
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