Last active
August 29, 2015 13:57
-
-
Save damonjmurray/9733097 to your computer and use it in GitHub Desktop.
A FizzBuzz solution that collapses a string array using string.Join to produce the desired output
This file contains hidden or 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
using System; | |
using System.Linq; | |
namespace FizzBuzzCollapsedStringArray | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
Enumerable.Range(1, 100).Select(i => string.Join(string.Empty, new[] | |
{ | |
i%3 == 0 ? "Fizz" : string.Empty, | |
i%5 == 0 ? "Buzz" : string.Empty, | |
(i%3)*(i%5) != 0 ? i.ToString() : string.Empty | |
})).ToList().ForEach(Console.WriteLine); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment