斐波那契数的关键就是下述:
F(0) = 0, F(1) = 1 F(N) = F(N - 1) + F(N - 2), 其中 N > 1.
很简单:
class Solution { public int fib(int N) { if(N == 0) { return 0; } if(N == 1) { return 1; } int s; s = fib(N-1) + fib(N-2); return s; } }
原文:https://www.cnblogs.com/wzwi/p/10958552.html