Easy-to-import Python module with a basic, efficient, native implementation of the extended Euclidean algorithm.
Project description
Easy-to-import Python module with a basic, efficient, native implementation of the extended Euclidean algorithm.
Package Installation and Usage
The package is available on PyPI:
python -m pip install egcd
The library can be imported in the usual way:
from egcd import egcd
The function egcd is an efficient implementation of the extended Euclidean algorithm. It accepts two integer inputs b and n, returning a tuple of the form (gcd(b, n), a, m) where the three integers in the tuple satisfy the identity (a * b) + (n * m) = gcd(b, n):
>>> egcd(1, 1) (1, 0, 1) >>> egcd(12, 8) (4, 1, -1) >>> egcd(23894798501898, 23948178468116) (2, 2437250447493, -2431817869532) >>> egcd(pow(2, 50), pow(3, 50)) (1, -260414429242905345185687, 408415383037561)
Testing and Conventions
All unit tests are executed and their coverage is measured when using nose (see setup.cfg for configuration details):
python -m pip install nose coverage nosetests --cover-erase
Alternatively, all unit tests are included in the module itself and can be executed using doctest:
python egcd/egcd.py -v
Style conventions are enforced using Pylint:
python -m pip install pylint pylint egcd
Contributions
In order to contribute to the source code, open an issue or submit a pull request on the GitHub page for this library.
Versioning
Beginning with version 0.1.0, the version number format for this library and the changes to the library associated with version number increments conform with Semantic Versioning 2.0.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file egcd-0.2.0.tar.gz
.
File metadata
- Download URL: egcd-0.2.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.26.0 setuptools/58.1.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d5f75b70b9ac432ad7244280cc42fa6b4fcc7c9b4d12614853ab863c948b58c |
|
MD5 | 40f6e6bfc27f5131991a4ec4b96ad07d |
|
BLAKE2b-256 | ec08032bb3feca9c4282673877a2aa267e1d28b5e6e8a4b9cf0c2e17959f7afc |
File details
Details for the file egcd-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: egcd-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.26.0 setuptools/58.1.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf81b35f498bf175ea656ec0d2f802783940363f294d8b33579c4bb8b5431be5 |
|
MD5 | 1b0a2f75d4b44ad4e62ecc5e0200a953 |
|
BLAKE2b-256 | 617f65ecbd4e3192b83685de762e8c3295a4307dddacce20b50fbe0bae98ac4d |