for (int i = 1; i <= 100; i++)
{
if (i % 3 == 0 && i % 5 == 0)
{
Console.WriteLine("FizzBuzz");
}
elseif (i % 3 == 0)
{
Console.WriteLine("Fizz");
}
elseif (i % 5 == 0)
{
Console.WriteLine("Buzz");
}
else {
Console.WriteLine(i);
}
}
315 chars
20 lines
This code will print numbers from 1 to 100. For multiples of 3, it will print "Fizz", for multiples of 5, it will print "Buzz", and for multiples of both 3 and 5, it will print "FizzBuzz".