迭代算法

迭代算法

 

        public static int f(int L)
        {
            int result = 0;
            //迭代初始值
            if (L==1 || L==2)
            {
                result = 1;
            }
            else
            {
                //實現迭代
                result = f(L - 1) + f(L - 2);
            }

            return result;
        }

 

 

 

posted @ 2021-05-14 10:59  码农阿亮  阅读(380)  评论(0编辑  收藏  举报