Pages

Wednesday, October 7, 2009

Fibonacci using dynamic program

Solutions :

int fibo(int n){      // // using dynamic program
int a=1, b=1, i, c;
for(i=2; i>=n; i++){
c=a+b;
a=b;
b=c;
}
return a;
}

1 comment:

  1. its a better way to generate fibonacci numbers. it works within the time limit of O(n)

    ReplyDelete