Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mod-nest-exp-1.0.6.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

mod_nest_exp-1.0.6-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file mod-nest-exp-1.0.6.tar.gz.

File metadata

  • Download URL: mod-nest-exp-1.0.6.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

Hashes for mod-nest-exp-1.0.6.tar.gz
Algorithm Hash digest
SHA256 025bbdc1d18466d69b41053e812f268f261eb2fd6d4016006f642b7bdd284c83
MD5 c805f812a01ab3033d6776585b6276ed
BLAKE2b-256 3ccc1791f06a83d5cfa371640a481d234c961672ff6cf14df9a318c13a0621c8

See more details on using hashes here.

File details

Details for the file mod_nest_exp-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: mod_nest_exp-1.0.6-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

Hashes for mod_nest_exp-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 339b793234101a01c29f9fc7036fd81162872e234758041f3d8528d53088b48e
MD5 0c3b85a761ded2303c6a865e03a082de
BLAKE2b-256 4216e763dc5842ce65e996995fac0efefc4e98788d6c3e2af6f80545da5f50a9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page