Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,18 +1,18 @@
|
|||
int fib(int n) {
|
||||
if(n==0 || n==1) {
|
||||
if (n==0 || n==1) {
|
||||
return n;
|
||||
}
|
||||
int prev=1;
|
||||
int current=1;
|
||||
for(int i=2;i<n;i++) {
|
||||
int next=prev+current;
|
||||
prev=current;
|
||||
current=next;
|
||||
var prev=1;
|
||||
var current=1;
|
||||
for (var i=2; i<n; i++) {
|
||||
var next = prev + current;
|
||||
prev = current;
|
||||
current = next;
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
int fibRec(int n) => n==0||n==1 ? n : fibRec(n-1)+fibRec(n-2);
|
||||
int fibRec(int n) => n==0 || n==1 ? n : fibRec(n-1) + fibRec(n-2);
|
||||
|
||||
main() {
|
||||
print(fib(11));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue