Skip to content

Instantly share code, notes, and snippets.

@jumboly
Created April 4, 2012 13:53
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/2301243 to your computer and use it in GitHub Desktop.
Save jumboly/2301243 to your computer and use it in GitHub Desktop.
FizzBuzz 2012/04/04
using System;
using System.Linq;
class Program {
static void Main() {
var fz = fizzbuzz();
foreach (var i in Enumerable.Range(1, 100)) {
Console.WriteLine(fz());
}
}
static Func<object> fizzbuzz() {
int i = 0;
return () => {
++i;
var s = "";
s += i % 3 == 0 ? "Fizz" : "";
s += i % 5 == 0 ? "Buzz" : "";
s += s == "" ? "" + i : "";
return s;
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment