Skip to content

Instantly share code, notes, and snippets.

@mathiassoeholm
Last active December 14, 2015 22:49
Show Gist options
  • Save mathiassoeholm/5161225 to your computer and use it in GitHub Desktop.
Save mathiassoeholm/5161225 to your computer and use it in GitHub Desktop.
FizzBuzz in one line
using System;
using System.Linq;
class FizzBuzz
{
static void Main()
{
Console.WriteLine(
String.Join(
Environment.NewLine,
Enumerable.Range(1, 100)
.Select(n => n % 15 == 0 ? "FizzBuzz"
: n % 3 == 0 ? "Fizz"
: n % 5 == 0 ? "Buzz"
: n.ToString())
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment