diff --git a/ArithmeticServer.js b/ArithmeticServer.js index 764039b..fe5ab7d 100644 --- a/ArithmeticServer.js +++ b/ArithmeticServer.js @@ -68,10 +68,5 @@ console.log('running - listening on port ', port); function fibonaci(n) { - if ((1 == n) || (0 == n) ) { - return 1; - } - else { - return (fibonaci(n-1) + fibonaci(n-2)); - } + return(Math.pow((1+Math.sqrt(5))/2,n)-Math.pow((1-Math.sqrt(5))/2,n))/Math.sqrt(5); } \ No newline at end of file diff --git a/Fibo1.js b/Fibo1.js index 6cba7e8..c84528e 100644 --- a/Fibo1.js +++ b/Fibo1.js @@ -2,12 +2,7 @@ * Created by User on 3/17/14. */ function fibonaci(n) { - if ((1 == n) || (0 == n) ) { - return 1; - } - else { - return (fibonaci(n-1) + fibonaci(n-2)); - } + return (Math.pow((1+Math.sqrt(5))/2,n)-Math.pow((1-Math.sqrt(5))/2,n))/Math.sqrt(5); } console.log('num is', fibonaci(20)); \ No newline at end of file