Created
March 29, 2012 14:17
-
-
Save jumboly/2237901 to your computer and use it in GitHub Desktop.
FizzBuzz 2012/03/29
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
using System; | |
using System.Linq; | |
namespace FB0329 { | |
class Program { | |
static void Main(string[] args) { | |
Func<int, bool> fizz = x => x % 3 == 0, buzz = x => x % 5 == 0; | |
Action<object> cw = x => Console.WriteLine(x.ToString()); | |
foreach (var i in Enumerable.Range(1, 100)) { | |
if (fizz(i) && buzz(i)) cw("FizzBuzz"); | |
else if (fizz(i)) cw("Fizz"); | |
else if (buzz(i)) cw("Buzz"); | |
else cw(i); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment