Skip to content

Instantly share code, notes, and snippets.

@damonjmurray
Created March 23, 2014 21:34
Show Gist options
  • Save damonjmurray/9730226 to your computer and use it in GitHub Desktop.
Save damonjmurray/9730226 to your computer and use it in GitHub Desktop.
A FizzBuzz solution with no if statements or ternary operators
using System;
namespace FizzBuzzNoSelection
{
public class Program
{
public static void Main(string[] args)
{
for (int i = 1; i <= 100; i++)
{
var index = 2 * (1 - Math.Sign(i%5)) + (1 - Math.Sign(i%3));
var item = (i + ",Fizz,Buzz,FizzBuzz").Split(',')[index];
Console.WriteLine(item);
}
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment