{"id":25360481,"url":"https://github.com/avivbrook/modular-nested-exponentiation","last_synced_at":"2026-05-02T03:08:20.578Z","repository":{"id":57442697,"uuid":"348651798","full_name":"avivbrook/modular-nested-exponentiation","owner":"avivbrook","description":"An algorithm that computes modular nested exponentiation efficiently.","archived":false,"fork":false,"pushed_at":"2025-08-25T21:44:09.000Z","size":1194,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-27T05:26:21.389Z","etag":null,"topics":["algorithm","computational-number-theory","jupyter-notebook","modular-arithmetic","modular-exponentiation","number-theory","positive-integers","pypi","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/avivbrook.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-17T09:32:38.000Z","updated_at":"2025-08-25T21:44:12.000Z","dependencies_parsed_at":"2022-09-26T17:21:19.241Z","dependency_job_id":null,"html_url":"https://github.com/avivbrook/modular-nested-exponentiation","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/avivbrook/modular-nested-exponentiation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avivbrook%2Fmodular-nested-exponentiation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avivbrook%2Fmodular-nested-exponentiation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avivbrook%2Fmodular-nested-exponentiation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avivbrook%2Fmodular-nested-exponentiation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avivbrook","download_url":"https://codeload.github.com/avivbrook/modular-nested-exponentiation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avivbrook%2Fmodular-nested-exponentiation/sbom","scorecard":{"id":218406,"data":{"date":"2025-08-11","repo":{"name":"github.com/avivbrook/modular-nested-exponentiation","commit":"f08fe00d7a5ad5b90d3a843cbd0b00c7970bfb3f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/23 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/release.yml:1","Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/avivbrook/modular-nested-exponentiation/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/avivbrook/modular-nested-exponentiation/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/avivbrook/modular-nested-exponentiation/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/avivbrook/modular-nested-exponentiation/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:43: update your workflow using https://app.stepsecurity.io/secureworkflow/avivbrook/modular-nested-exponentiation/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/avivbrook/modular-nested-exponentiation/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/avivbrook/modular-nested-exponentiation/test.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/avivbrook/modular-nested-exponentiation/test.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/release.yml:38","Warn: pipCommand not pinned by hash: .github/workflows/release.yml:40","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:35","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:37","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:39","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:41","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   0 out of   6 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: GNU General Public License v3.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":8,"reason":"2 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-29gw-9793-fvw7","Warn: Project is vulnerable to: PYSEC-2022-12 / GHSA-pq7m-3gw7-gq5x"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T02:04:01.000Z","repository_id":57442697,"created_at":"2025-08-17T02:04:01.000Z","updated_at":"2025-08-17T02:04:01.000Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32521126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T01:12:54.858Z","status":"online","status_checked_at":"2026-05-02T02:00:05.923Z","response_time":132,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","computational-number-theory","jupyter-notebook","modular-arithmetic","modular-exponentiation","number-theory","positive-integers","pypi","python"],"created_at":"2025-02-14T21:54:16.118Z","updated_at":"2026-05-02T03:08:20.562Z","avatar_url":"https://github.com/avivbrook.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Modular nested exponentiation\n\nAn algorithm that computes modular nested exponentiation efficiently.\n\n\u003c!-- [![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/avivbrook/modular-nested-exponentiation/Test/master?logo=github\u0026style=flat-square)](https://github.com/avivbrook/modular-nested-exponentiation/actions) --\u003e\n[![PyPI - License](https://img.shields.io/pypi/l/mod-nest-exp?style=flat-square)](https://choosealicense.com/licenses/gpl-3.0/)\n[![Source](https://img.shields.io/badge/source-GitHub-303030.svg?style=flat-square)](https://github.com/avivbrook/modular-nested-exponentiation/)\n[![codecov](https://codecov.io/gh/avivbrook/modular-nested-exponentiation/branch/master/graph/badge.svg?token=5CWMO8OLNU)](https://codecov.io/gh/avivbrook/modular-nested-exponentiation)\n[![PyPI](https://img.shields.io/pypi/v/mod-nest-exp?style=flat-square)](https://pypi.org/project/mod-nest-exp/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mod-nest-exp?style=flat-square)](https://pypi.org/project/mod-nest-exp/#files)\n\u003c!-- [![PyPI - Wheel](https://img.shields.io/pypi/wheel/mod-nest-exp?style=flat-square)](https://pypi.org/project/mod-nest-exp/#files) --\u003e\n\u003c!-- [![GitHub issues](https://img.shields.io/github/issues/avivbrook/modular-nested-exponentiation?style=flat-square)](https://github.com/avivbrook/modular-nested-exponentiation/issues) --\u003e\n[![Downloads](https://img.shields.io/badge/dynamic/json?style=flat-square\u0026color=303f9f\u0026label=downloads\u0026query=%24.total_downloads\u0026url=https%3A%2F%2Fapi.pepy.tech%2Fapi%2Fprojects%2Fmod-nest-exp)](https://pepy.tech/project/mod-nest-exp)\n\n## 🚩 Table of Contents\n- [Overview](#%EF%B8%8F-overview)\n- [Prerequisites](#%EF%B8%8F-prerequisites)\n- [Installation](#-installation)\n- [Examples](#-examples)\n\n## 🗺️ Overview\n\n`mod-nest-exp` exports a Python function `mod_nest_exp` 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).\n\nTo date, this problem was not solvable by computers in the general case.\n\n## 🏳️ Prerequisites\n\n`mod-nest-exp` requires Python v3.6+.\n\nFor best performance, install `gmpy2` and `sympy`:\n```console\n$ apt install libgmp-dev libmpfr-dev libmpc-dev # required for gmpy2\n$ pip install gmpy2 sympy\n```\n\nThe libraries offer more efficient alternatives to a number of functions used as subroutines in the core module.\n\n## 🔧 Installation\n\nThe recommended installation method is from [PyPI](https://pypi.org/project/mod-nest-exp/):\n```console\n$ pip install mod-nest-exp\n```\n\nA development version can be installed from GitHub source using `setuptools`:\n```console\n$ git clone https://github.com/avivbrook/modular-nested-exponentiation.git\n$ cd modular-nested-exponentiation\n$ python setup.py install\n```\n\n## 💡 Examples\n\n### Small inputs\n\n```python\n\u003e\u003e\u003e from mod_nest_exp import mod_nest_exp\n\u003e\u003e\u003e mod_nest_exp([6,5,4,3,2], 1948502738) # 6^(5^(4^(3^2))) mod 1948502738\n951546056\n```\n\n### Larger inputs\n\nHere we demonstrate a computation that is not possible with simple modular exponentiation functions such as `pow`:\n```python\n\u003e\u003e\u003e from random import randint\n\u003e\u003e\u003e seq = [randint(1, 2**64) for _ in range(5)]\n\u003e\u003e\u003e seq\n[6038140174510300905, 11769918488496772646, 2874847465098133786, 9008748983185995190, 13009674817390511365]\n\u003e\u003e\u003e m = randint(1, 2**64)\n\u003e\u003e\u003e m\n6790053138492639247\n\u003e\u003e\u003e mod_nest_exp(seq, m)\n3426314670852891859\n```\n\n### Benchmark the main function\n\n```python\n\u003e\u003e\u003e from mod_nest_exp.core.benchmarks import benchmark_core\n\u003e\u003e\u003e benchmark_core(list_lengths=(10, 100, 1000), bit_lengths=(16, 128, 1024), mod_bit_lengths=(16, 32, 64))\nRunning mod_nest_exp on sequences of l pseudorandom b-bit positive integers over a B-bit modulus (1000 runs per table entry)\n=================================================================\n                            sequence length l\n                  10               100               1000\n          ----------------- ----------------- -----------------\n  B     b     mean    stdev     mean    stdev     mean    stdev\n-----------------------------------------------------------------\n       16 |   0.08     0.04     0.08     0.03     0.10     0.03\n 16   128 |   0.08     0.11     0.08     0.03     0.10     0.04\n     1024 |   0.08     0.03     0.08     0.03     0.11     0.04\n-----------------------------------------------------------------\n       16 |   0.34     0.32     0.34     0.24     0.35     0.24\n 32   128 |   0.33     0.23     0.34     0.23     0.36     0.23\n     1024 |   0.33     0.22     0.33     0.24     0.37     0.24\n-----------------------------------------------------------------\n       16 |   8.82    34.83     6.20    21.27     7.18    30.35\n 64   128 |   7.66    30.70     6.71    22.72     7.60    26.92\n     1024 |   5.94    25.10     6.67    20.78     6.76    26.28\n=================================================================\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favivbrook%2Fmodular-nested-exponentiation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favivbrook%2Fmodular-nested-exponentiation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favivbrook%2Fmodular-nested-exponentiation/lists"}