Skip to content

Fibonacci Matrix doesn't use BigInts #1047

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

Closed
Rudxain opened this issue Jun 20, 2022 · 1 comment · Fixed by #1049
Closed

Fibonacci Matrix doesn't use BigInts #1047

Rudxain opened this issue Jun 20, 2022 · 1 comment · Fixed by #1049
Assignees
Labels
algorithm Adds or improves an algorithm feature Adds a new feature in progress Being worked on

Comments

@Rudxain
Copy link
Contributor

Rudxain commented Jun 20, 2022

This file uses Numbers at the matrix algorithm to compute the nth number in the Fibonacci sequence. My reasons to recommend BigInt are these:

  • BigInts can't use Binet's Formula, nor the rounded and simpler variant because that requires arbitrary-precision floating-point computation
  • The repeated-addition algo is more suitable for generator functions, but the matrix algo is used to get as fast as possible to the nth term in the sequence, regardless of the exponent value, without sequentially "touching" every term in the sequence
  • Exponentiation (matrix or not) usually yields huge numbers, BigInts are more suitable for this task. Using Numbers would usually return Infinity
  • All numbers used are integers, no need for floating-point or fixed-point

I want to make a PR, but I opened this issue to wait for approval

@appgurueu appgurueu added feature Adds a new feature algorithm Adds or improves an algorithm labels Jun 21, 2022
@appgurueu
Copy link
Collaborator

I approve this. Go ahead and open your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
algorithm Adds or improves an algorithm feature Adds a new feature in progress Being worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants