Skip to content

Instantly share code, notes, and snippets.

@jumboly
Created March 29, 2012 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jumboly/2237901 to your computer and use it in GitHub Desktop.
Save jumboly/2237901 to your computer and use it in GitHub Desktop.
FizzBuzz 2012/03/29
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