I do feel like this was kinda cheap...
using System; using System.Collections.Generic; using System.Linq; public class Program { public static void Main() { foreach(var s in FizzBuzz().Take(15)) Console.WriteLine(s); } public static IEnumerable<string> FizzBuzz() { for(int i = 1; true; i++) { for(;i%3!=0 && i%5!=0;) { yield return i.ToString(); break; } for(;i%3==0;) { for(;i%5==0;) { yield return "FizzBuzz"; break; } yield return "Fizz"; break; } for(;i%5==0;) { yield return "Buzz"; break; } } } }
I like it!
Nice stuff! Cool use of a generator. And yeah kinda cheap but cool nonetheless, thanks for sharing!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I do feel like this was kinda cheap...
I like it!
Nice stuff! Cool use of a generator. And yeah kinda cheap but cool nonetheless, thanks for sharing!