fibonacci
is a script (written in Python 3) which computes any element of the
Fibonacci sequence with arbitrary precision. It implements the algorithm
described here.
All code from this project is licensed under the GPLv3. See the
LICENSE
file for more information.
The gmpy2
module is used. You can install it with the following command:
pip3 install gmpy2
On Ubuntu/Debian, you may need to install additional system packages before you
can install gmpy2
:
sudo apt install libmpfr-dev libmpc-dev
To get the N-th element of the Fibonacci sequence (N must be a nonnegative integer), run:
./fibonacci N
Python is capable of dealing with arbitrarily long integers by design, but GMPY is used instead for that purpose since it performs significantly better (for large values of N, using GMPY can reduce the execution time by orders of magnitude).
Diego Assencio / diego@assencio.com