Primes - Advanced Primality Testing Algorithms
A Python library implementing state-of-the-art primality testing algorithms, starting with the AKS (Agrawal-Kayal-Saxena) primality test.
Overview
This repository contains implementations of various primality testing algorithms with a focus on theoretical significance and practical applications. The AKS primality test is the first deterministic polynomial-time algorithm for testing primality.
Features
- AKS Primality Test: First deterministic polynomial-time primality test
- Comprehensive Documentation: Detailed explanations of algorithms and mathematical foundations
- Performance Analysis: Benchmarking and complexity analysis
- Examples and Tutorials: Step-by-step examples demonstrating algorithm usage
Installation
pip install -e .
Quick Start
from primes.aks import AKSPrimalityTest
# Create an instance of the AKS test
aks = AKSPrimalityTest()
# Test if a number is prime
result = aks.is_prime(31)
print(f"31 is prime: {result}") # True
# Get detailed step-by-step execution
result_detailed = aks.is_prime_detailed(31)
print(result_detailed)
Algorithms Implemented
AKS Primality Test
- Time Complexity: O(log^6 n) (theoretical), optimized versions available
- Space Complexity: O(log^3 n)
- Deterministic: Yes
- Paper: PRIMES is in P
Project Structure
primes/
├── src/
│ └── primes/
│ ├── __init__.py
│ ├── aks/
│ │ ├── __init__.py
│ │ ├── core.py
│ │ └── optimizations.py
│ └── utils/
│ ├── __init__.py
│ ├── math_utils.py
│ └── polynomial.py
├── tests/
│ ├── __init__.py
│ ├── test_aks.py
│ └── test_utils.py
├── examples/
│ ├── basic_usage.py
│ ├── performance_comparison.py
│ └── step_by_step_aks.py
├── docs/
│ ├── algorithms/
│ │ └── aks.md
│ └── mathematical_foundations.md
├── benchmarks/
│ └── aks_benchmark.py
├── requirements.txt
├── setup.py
└── README.md
Contributing
Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
References
- Agrawal, M., Kayal, N., & Saxena, N. (2004). PRIMES is in P. Annals of Mathematics, 160(2), 781-793.
- AKS Primality Test - Wikipedia
Acknowledgments
- Inspired by the VaidhyaMegha/optimization_algorithms repository structure
- Mathematical foundations based on the original AKS paper
Metadata
Release files for number-theory-primes 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| number_theory_primes-0.1.2.tar.gz | 11.4 kB | Without provenance | Details for number_theory_primes-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| number_theory_primes-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for number_theory_primes-0.1.2-py3-none-any.whl |
Total release size: 21.7 kB
Release files / number_theory_primes-0.1.2.tar.gz
| Download URL | number_theory_primes-0.1.2.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a467c393ae8e6280e122fb864ea616991a68273279230b372c2c59fee589647d
|
|
BLAKE2b-256 checksum How to use checksums |
aecc60c2b12c36deac36fac77cb60710e587a2878129886c0964bf0dde941848
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / number_theory_primes-0.1.2-py3-none-any.whl
| Download URL | number_theory_primes-0.1.2-py3-none-any.whl |
|---|---|
| Size | 10.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ab03a132d9d6fa948d8185dbbcdd3aeb96f75a1cb1f8ebe837e9b53bd8f019ff
|
|
BLAKE2b-256 checksum How to use checksums |
ba7ae3a34bb636fa8fdbea078c92f4a255239686832e2b3dbe17d952dcc66038
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for number-theory-primes 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.