Last active
August 29, 2015 14:06
-
-
Save Mikescher/27f9fd0451396135be01 to your computer and use it in GitHub Desktop.
LINQ - FizzBuzz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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