for(int i = 1; i <= 100; i++)
{
if (i % 3 == 0) System.Console.WriteLine("Fizz");
if (i % 5 == 0) System.Console.WriteLine("Buzz");
if (i % 3 == 0 && i % 5 == 0) System.Console.WriteLine("FizzBuzz");
}
Console.ReadLine();
The read out is the same thing and unless you're running this calculation one hundred thousand times per millisecond, I'm not sure it would make big difference other than the few characters you saved typing. In which case, it might also be better not to use "System.Console.Writeline()" 3 times but instead assign a string variable string s; [...] s = "Fizz" etc, [...]WriteLine(s); etc etc. for a net savings in typed characters.
View all comments
0
u/[deleted] Jan 17 '14
FizzBuzz Program:
+/u/CompileBot C#