2
2

More than 5 years have passed since last update.

C#でFizzBuzz

Posted at

Qiitaデビュー記念にC#でFizzBuzzをば

fizzbuzz.cs
using System;
using System.Linq;

namespace HelloQiita
{
  class HelloQiita
  {
    static void Main(string[] args)
    {
      var fizzbuzz = Enumerable.Range(0, int.MaxValue)
                .Skip(1)
                .Take(100)
                .Select(x =>
                  x % 15 == 0 ? "Fizz Buzz" :
                  x % 3 == 0 ? "Fizz" :
                  x % 5 == 0 ? "Buzz" :
                  x.ToString()
                );
      foreach (var item in fizzbuzz)
      {
        Console.WriteLine(item);
      }
    }
  }
}

LIQNは便利ですね。まる。

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