An algorithm that computes modular nested exponentiation efficiently
Project description
modular-nested-exponentiation
An algorithm that computes modular nested exponentiation efficiently.
License | Version | ||
Wheel | Implementation | ||
Supported versions | Downloads |
Generalised modular exponentiation
We present an algorithm that takes as input an arbitrarily long sequence of positive integers a₁, a₂, a₃, ..., aₙ
and a positive integer m
and computes a₁^(a₂^(···^aₙ)) mod m
efficiently (that is, without computing the value of the nested exponent).
Without this algorithm, this type of computation is unfeasible for modern computers even for short input sequences containing small integers.
Prerequisites
sympy
is currently required as the algorithm uses its totient
function. gmpy2
is not required but offers more efficient versions to some of Python's built-in math functions.
In the future, a custom totient
function will be added so that sympy
is not required and the module will be self-contained.
$ apt install libgmp-dev libmpfr-dev libmpc-dev # for gmpy2
$ pip install sympy gmpy2
Install
$ pip install mod-nest-exp
Usage
$ python
>>> from mod_nest_exp import mod_nest_exp
>>> mod_nest_exp([6, 5, 4, 3, 2], 1948502738)
mpz(951546056) # uses gmpy2 if available
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 mod-nest-exp-1.0.7.tar.gz
.
File metadata
- Download URL: mod-nest-exp-1.0.7.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.1+
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f332cf76a8762073718971e4b0123e501db6a5be9805c6aed1ab694f554242eb |
|
MD5 | 8c8a963251f42ad0693474b77b3d084e |
|
BLAKE2b-256 | 0a53806ff6e5616e0319091aa22df2ebabd7216f584cf43da072001223849d2d |
File details
Details for the file mod_nest_exp-1.0.7-py3-none-any.whl
.
File metadata
- Download URL: mod_nest_exp-1.0.7-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.1+
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a89395b231c20603acb250e4a8202fee7ddd1de98000528e89571542176f08d6 |
|
MD5 | a59f28e4970ca8e5d3030d4281141adb |
|
BLAKE2b-256 | f39d30583bf50ab5416ff39daaca63c8d2981fac5e6c5cb24f22280a0e1f8d26 |