Skip to content

Update FibonacciNumber.java#4195

Merged
debasishbsws merged 1 commit intoTheAlgorithms:masterfrom
Indrranil:patch-1
May 21, 2023
Merged

Update FibonacciNumber.java#4195
debasishbsws merged 1 commit intoTheAlgorithms:masterfrom
Indrranil:patch-1

Conversation

@Indrranil
Copy link
Copy Markdown
Contributor

In this optimized version, we calculate 5 * number * number + 4 and 5 * number * number - 4 only once and store them in separate variables. This avoids the duplicate calculation in the return statement.

  • [x ] I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • [ x] All filenames are in PascalCase.
  • [x ] All functions and variable names follow Java naming conventions.
  • [ x] All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.

Copy link
Copy Markdown
Member

@debasishbsws debasishbsws left a comment

Choose a reason for hiding this comment

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

Looks good thanks.

@debasishbsws debasishbsws merged commit 9ce275c into TheAlgorithms:master May 21, 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.

2 participants