An algorithm that computes modular nested exponents (or towers) efficiently.
Project description
modular-towers
An algorithm that computes modular nested exponents (or towers) efficiently.
🚩 Table of Contents
🗺️ Overview
modular-towers
exports a Python function mod_tower
that takes as input an arbitrarily long sequence of positive integers 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).
🔧 Installing
Installing with pip
is the easiest:
$ pip install modular-towers
A development version can be installed from GitHub
using setuptools
, provided you have sympy
installed already:
$ git clone https://github.com/avivbrook/modular-towers
$ cd modular-towers
$ python setup.py install
💡 Examples
>>> from modular_towers import mod_tower as modtow
>>> modtow([6,5,4,3,2], 1948502738) # 6^(5^(4^(3^2))) mod 1948502738
951546056
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
Built Distribution
File details
Details for the file modular-towers-0.1.tar.gz
.
File metadata
- Download URL: modular-towers-0.1.tar.gz
- Upload date:
- Size: 17.0 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.59.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | be3aea945c10de9107f878d4ae1725effa0c4238b5135cd477a88e630fb484b5 |
|
MD5 | af44a58ec2843df91adb1b2b20121d40 |
|
BLAKE2b-256 | 2490fffc128a8f90902e42c0765efbc79400cd252e40d66e4afa7302339a66d9 |
File details
Details for the file modular_towers-0.1-py3-none-any.whl
.
File metadata
- Download URL: modular_towers-0.1-py3-none-any.whl
- Upload date:
- Size: 17.2 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.59.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 269a2d455145ad45129d79c541ba94595fd638073e975b1ad64ffbbd5ff9c0b2 |
|
MD5 | d55707a62178d5be2c1fb960428d6402 |
|
BLAKE2b-256 | 2765b5fbacaba0ae5a0cfc349b3e9153c19c5d9c2a14541b7cca1742ef450c7d |