Skip to content

Instantly share code, notes, and snippets.

@ProgramistycznySwir
Created March 23, 2021 21:15
Show Gist options
  • Save ProgramistycznySwir/3346745cfeee835291fa3894df1dedbf to your computer and use it in GitHub Desktop.
Save ProgramistycznySwir/3346745cfeee835291fa3894df1dedbf to your computer and use it in GitHub Desktop.
FizzBuzz oneliner in C#
int n = 100;
Console.WriteLine(string.Join('\n',Enumerable.Range(0, n).Select(i => ((i % 3 == 0 ? "Fizz" : "") + (i % 5 == 0 ? "Buzz" : "")) is string ii ? (ii != "" ? ii : i.ToString()) : "")));
@ProgramistycznySwir
Copy link
Author

using System;using System.Linq;public class Program{public static void Main()=>Console.WriteLine(string.Join('\n',Enumerable.Range(0,100).Select(i=>((i%3==0?"Fizz":"")+(i%5==0?"Buzz":""))is string ii?(ii!=""?ii:i.ToString()):"")));}

I've simplified it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment