Skip to content

Improve efficiency of fibonacci using closed form #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions ArithmeticServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add unit tests!

}
7 changes: 1 addition & 6 deletions Fibo1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please log properly using loacker

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the PR's with minimal changes, if you think we should change this log please create a separate PR for it
@MoLow