Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save damonjmurray/9730383 to your computer and use it in GitHub Desktop.
Save damonjmurray/9730383 to your computer and use it in GitHub Desktop.
A FizzBuzz solution that uses a Custom Numeric Format string to produce the desired output
using System;
namespace FizzBuzzCustomNumericFormatter
{
public class Program
{
public static void Main(string[] args)
{
const string format = "{0:#;}{1:;;Fizz}{2:;;Buzz}";
for (int i = 1; i <= 100; i++)
Console.WriteLine(format, i % 3 * i % 5 == 0 ? 0 : i, i % 3, i % 5);
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment