LoginSignup
2
2

More than 5 years have passed since last update.

最初の記事はFizzBuzzで。I love C#!

Posted at

ようやくQiitaにアカウントを作り、何か投稿しようと思ったのですが、まずは毒にも薬にもならぬFizzBuzzから書いてみます。
役に立たない記事でごめんなさい m(_ _)m

FizzBuzz.cs
using System;
using System.Linq;

namespace Sample {
    class Program {
        static void Main(string[] args) {

            Enumerable
                .Range(1, 100)
                .Select(FizzBuzz)
                .ToList()
                .ForEach(Console.WriteLine);

            string FizzBuzz(int num) =>
                num % 15 == 0 ? "FizzBuzz" :
                num % 3 == 0 ? "Fizz" :
                num % 5 == 0 ? "Buzz" :
                num.ToString();
        }
    }
}

無難にもほどがあるコードですが、ご挨拶までに。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2