Recursive Functions (58)

16 Name: #!/usr/bin/anonymous : 2008-02-14 22:22 ID:2PCxkD+p

>>10
a javascript fibonacci function that runs in constant time:

function fib(n){
var p=Math.sqrt(5);
return (1/p)*(Math.pow((1+p)/2,n)-Math.pow(2/(1+p),n)*Math.cos(n*Math.PI));
}
This thread has been closed. You cannot post in this thread any longer.