首页 > 其他分享> > 斐波那契数 斐波那契数 2022-02-01 13:04:05 作者:互联网 斐波那契数 class Solution { public int fib(int n) { if (n < 2) return n; int p = 0, q = 0, ans = 1; //滑动数组 for (int i = 2; i <= n; i ++) { p = q; q = ans; ans = p + q; } return ans; } } 标签:契数,return,int,Solution,斐波,ans 来源: https://blog.csdn.net/qq_43806430/article/details/122763565