Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace FizzBuzz
- {
- static class Program
- {
- static void Main()
- {
- for (var i = 1; i <= 100; i++)
- {
- Console.WriteLine(FizzBuzz(i));
- }
- string FizzBuzz(int value) => (value % 3, value % 5) is var t && t.Item1 == 0 || t.Item2 == 0
- ? $"{NameIfZero(t.Item1, "Fizz")}{NameIfZero(t.Item2, "Buzz")}"
- : value.ToString();
- string NameIfZero(int value, string name) => value == 0 ? name : "";
- }
- }
- }
Add Comment
Please, Sign In to add comment