标签:coding 题目 sel 输入 要求 des odi sub --
n<=39
class Solution {
public:
int Fibonacci(int n) {
int f=0,g=1;
while (n--){
g+=f;
f=g-f;
}
return f;
}
};
public class Solution {
public int Fibonacci(int n) {
int target=0;
if (n==0)
return 0;
if (n==1)
return 1;
int one=0,two=1;
for (int i=2;i<=n;i++){
target=one+two;
one=two;
two=target;
}
return target;
}
}
# -*- coding:utf-8 -*-
class Solution:
def Fibonacci(self, n):
# write code here
f1=0
f2=1
for i in range(n):
f1,f2=f2,f1+f2
return f1
标签:coding 题目 sel 输入 要求 des odi sub --
原文地址:https://www.cnblogs.com/hrnn/p/13359009.html