剑指offer(7)斐波那契数列
public class Solution {
public int Fibonacci(int n) {
int a = 1,b = 1,c = 0;
if(n <= 0){
return 0;
}else if(n == 1 || n == 2){
return 1;
}else{
for(int i = 3;i <= n;i++){
c = a + b;
a = b;
b = c;
}
return c;
}
}
}