Skip to content

Instantly share code, notes, and snippets.

@Mikescher
Last active August 29, 2015 14:06
Show Gist options
  • Save Mikescher/27f9fd0451396135be01 to your computer and use it in GitHub Desktop.
Save Mikescher/27f9fd0451396135be01 to your computer and use it in GitHub Desktop.
LINQ - FizzBuzz
Enumerable.Range(1, 100)
.Select(p => ((p%3==0) ? 2 : 0) | ((p%5==0) ? 1 : 0))
.Select((p, i) => new string[]
{
(i+1)+"",
"Fizz",
"Buzz",
"FizzBuzz"
}[p])
.Aggregate((a, b) => a + Environment.NewLine + b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment