using System;
namespace 斐波那契
{
    class Program
    {
        static void Main(string[] args)
        {
            UInt32 n;
            Console.WriteLine("输入求结果的个数值:");
            n = Convert.ToUInt32(Console.ReadLine());
            if (n == 1)
            {
                Console.WriteLine("第一个数为1");//第一个数没有不符合以下算法
            }
            else
            {
                int i, a = 0, b = 1, result = 1;
                for (i = 1; i < n; i++)//只有小于才能正确实现
                {
                    result = a + b;
                    a = b;
                    b = result;
                }
                Console.WriteLine("{0}个数为{1}", n, result);

            }
            Console.ReadKey();
        }
    }
}
(第一天)求斐波那契数列第n个数(第一天)求斐波那契数列第n个数

相关文章:

  • 2021-05-20
  • 2021-11-16
  • 2021-06-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-19
  • 2022-12-23
猜你喜欢
  • 2021-12-02
  • 2021-04-09
  • 2022-02-22
  • 2022-12-23
相关资源
相似解决方案