码迷,mamicode.com
首页 > 其他好文 > 详细

带有记忆的菲波那切数列

时间:2015-11-17 00:16:26      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:

    public static int Fib(int n)
    {
        int q=0;
        int []r=new int[n+1];
        r[0]=1;
        r[1]=1;
        for(int j=2;j<=n;j++)
        {
            r[j]=r[j-1]+r[j-2];
        }
        return r[n];
    }

 

带有记忆的菲波那切数列

标签:

原文地址:http://www.cnblogs.com/liuhg/p/Fib.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!