Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -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));