Skip to content

Fibonacci Matrix doesn't use BigInts #1047

@Rudxain

Description

@Rudxain

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

Metadata

Metadata

Assignees

Labels

algorithmAdds or improves an algorithmfeatureAdds a new featurein progressBeing worked on

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions