Created
March 23, 2021 21:15
-
-
Save ProgramistycznySwir/3346745cfeee835291fa3894df1dedbf to your computer and use it in GitHub Desktop.
FizzBuzz oneliner in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) : ""))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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