プログラミング初心者用のC#サンプルプログラム

```
using System;
using System.Text;

namespace Sample
{
    class Program
    {
        const int listSizeMax = 100;
        static void Main(string[] args)
        {
            Prime();
            Console.ReadLine();
        }
        static void Fibonacchi()
        {
            var a = 0; var b = 1;
            for(var i = 0; i < listSizeMax; ++i)
            {
                try
                {
                    checked
                    {
                        var number = a + b;
                        Console.WriteLine($"{i}  {number}");
                        a = b;
                        b = number;

                    }

                }
                catch (Exception)
                {

                    Console.WriteLine($"{i} overflow");
                    break;
                }
            }
        }
        static void Prime()
        {
            var i = 0;
            for (var n = 2; n < int.MaxValue && i < listSizeMax; ++n)
            {
                try
                {
                    checked
                    {
                        var isPrime = IsPrime(n);
                        if (isPrime)
                        {
                            Console.WriteLine($"{i} {n}");
                            i++;

                        }
                    }

                }
                catch (Exception)
                {

                    Console.WriteLine($"{i} overflow");
                    break;
                }
            }
        }
        static void Binary()
        {
            for (var i = 0;  i < listSizeMax; ++i)
            {
                try
                {
                    checked
                    {
                        var buffer = new char[8] { '0', '0', '0', '0', '0', '0', '0', '0' };
                        var n = i;
                        var mask = 0b1;
                        for (var j = buffer.Length - 1; j >= 0; --j)
                        {
                            var bit = n & mask;
                            buffer[j] = (char)(bit + '0');
                            n = n >> 1;
                        }
                        var s = new string(buffer);
                        Console.WriteLine($"{i} {s}");

                    }
                }
                catch (Exception)
                {

                    Console.WriteLine($"{i} overflow");
                    break;
                }
            }
        }
        static void HexDecimal()
        {
            for (var i = 0; i < listSizeMax; ++i)
            {
                try
                {
                    checked
                    {
                        var buffer = new char[2] { '0', '0' };
                        var n = i;
                        var mask = 15;
                        for (var j = buffer.Length - 1; j >= 0; --j)
                        {
                            var unit = n & mask;
                            if(unit < 10)
                            {
                                buffer[j] = (char)(unit + '0');
                            }
                            else
                            {
                                buffer[j] = (char)(unit - 10 + 'a');
                            }
                            n = n >> 4;
                        }
                        var s = new string(buffer);
                        Console.WriteLine($"{i} {s}");

                    }
                }
                catch (Exception)
                {

                    Console.WriteLine($"{i} overflow");
                    break;
                }
            }
        }
        static bool IsPrime(int n)
        {
            var m = Math.Sqrt(n);
            for (var i = 2; i <= m; i++)
            {
                if(n % i == 0)
                {
                    return false;
                }
            }
            return true;
        }
    }
}
```