Skip to content

added fibonacci using formula along with test cases#1358

Merged
raklaptudirm merged 9 commits intoTheAlgorithms:masterfrom
dev-madhurendra:Fibonacci/Using-Formula
Sep 19, 2023
Merged

added fibonacci using formula along with test cases#1358
raklaptudirm merged 9 commits intoTheAlgorithms:masterfrom
dev-madhurendra:Fibonacci/Using-Formula

Conversation

@dev-madhurendra
Copy link
Copy Markdown
Contributor

Open in Gitpod know more

Describe your change:

I added a code which calculates the nth fibonacci number using formula in a very less time.

  • [ ✅ ] Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • [ ✅ ] I have read CONTRIBUTING.md.
  • [ ✅ ] This pull request is all my own work -- I have not plagiarized.
  • [ ✅ ] I know that pull requests will not be merged if they fail the automated tests.
  • [ ✅ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • [ ✅ ] All new JavaScript files are placed inside an existing directory.
  • [ ✅ ] All filenames should use the UpperCamelCase (PascalCase) style. There should be no spaces in filenames.
    Example:UserProfile.js is allowed but userprofile.js,Userprofile.js,user-Profile.js,userProfile.js are not
  • [ ✅ ] All new algorithms have a URL in their comments that points to Wikipedia or another similar explanation.
  • [ ✅ ] If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

Copy link
Copy Markdown
Collaborator

@appgurueu appgurueu left a comment

Choose a reason for hiding this comment

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

Please add this to the existing Fibonacci.js file (and add the tests to the corresponding test file). Use a proper JSDoc comment. Also, use each for the test cases.

The formula doesn't need to be a comment, that's redundant with the implementation (also, the formula in the comment seems to differ from the one you implemented?). You can use x**y instead of Math.pow(x, y). Note also that Wikipedia suggests a slightly simpler formula for computation by rounding.

Side note: I find calling this O(1) time/space complexity slightly misleading; this is only (trivially) given because the numbers involved have constant size. If this were to use bigints / bigdecimals, it wouldn't be constant time anymore.

appgurueu
appgurueu previously approved these changes Sep 11, 2023
@dev-madhurendra
Copy link
Copy Markdown
Contributor Author

@appgurueu When I'll be able to merge this PR ?

@appgurueu
Copy link
Copy Markdown
Collaborator

@appgurueu When I'll be able to merge this PR ?

It's still waiting on a second review from @raklaptudirm.

@dev-madhurendra dev-madhurendra marked this pull request as draft September 13, 2023 04:20
@dev-madhurendra dev-madhurendra marked this pull request as ready for review September 13, 2023 04:21
Copy link
Copy Markdown
Member

@raklaptudirm raklaptudirm left a comment

Choose a reason for hiding this comment

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

Sorry for the late review, but consider adding a resource to the formula used here.

@raklaptudirm raklaptudirm merged commit 268796b into TheAlgorithms:master Sep 19, 2023
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