1. 程式人生 > >C# 1,1,2,3,5.....第三十個數

C# 1,1,2,3,5.....第三十個數

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = 1, y = 1, i = 1 ;

            while ( ++i < 30)
            {
                int s = x + y;
                x = y;
                y = s;
            }
            Console.WriteLine("第三十個數值是:{0}",y);
            Console.ReadKey();
        }
    }
}

執行結果: