Skip to content

Conversation

@Linkgoron
Copy link

@Linkgoron Linkgoron commented Aug 18, 2019

Use the closed form of Fibonacci to improve efficiency and protect from stack overflow (not the website)

https://en.wikipedia.org/wiki/Fibonacci_number#Closed-form_expression
http://mathonline.wikidot.com/a-closed-form-of-the-fibonacci-sequence

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!

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants