using System; using System.Collections.Generic; using System.Linq; namespace FizzBuzz { static class Program { static IEnumerable<string> FizzBuzz() { for (var i = 1; ; i++) { var result = ""; if ( i % 3 == 0 ) result += "Fizz"; if ( i % 5 == 0 ) result += "Buzz"; yield return result == "" ? i.ToString() : result; } } static void Main(string[] args) { foreach ( var s in FizzBuzz().Take(100) ) { Console.WriteLine(s); } } } }