Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -1,6 +1,6 @@
|
|||
int fibRec(int n){
|
||||
if (n < 2)
|
||||
return n;
|
||||
else
|
||||
return fibRec(n - 1) + fibRec(n - 2);
|
||||
if (n < 2)
|
||||
return n;
|
||||
else
|
||||
return fibRec(n - 1) + fibRec(n - 2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
int fibIter(int n){
|
||||
if (n < 2)
|
||||
return n;
|
||||
|
||||
int last = 0;
|
||||
int cur = 1;
|
||||
int next;
|
||||
|
||||
for (int i = 1; i < n; ++i){
|
||||
next = last + cur;
|
||||
last = cur;
|
||||
cur = next;
|
||||
}
|
||||
|
||||
return cur;
|
||||
if (n < 2)
|
||||
return n;
|
||||
|
||||
int last = 0;
|
||||
int cur = 1;
|
||||
int next;
|
||||
|
||||
for (int i = 1; i < n; ++i){
|
||||
next = last + cur;
|
||||
last = cur;
|
||||
cur = next;
|
||||
}
|
||||
|
||||
return cur;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue