Computational number theory. Pure Python. Zero dependencies. Unreasonably fast.
Project description
Computational number theory. Pure Python. Zero dependencies. Unreasonably fast.
Installation
pip install numthy
Or save numthy.py directly into your project.
Quick Start
import numthy as nt
# Primality testing
nt.is_prime(2**89 - 1) # True (Mersenne prime)
# Factorization
nt.prime_factors(2**64 + 1) # (274177, 67280421310721)
# Modular arithmetic
nt.discrete_log(3, 1000, 2**16 + 1) # 50921
# Diophantine equations
solutions = nt.pell(2)
next(solutions) # (3, 2) since 3² - 2·2² = 1
Highlights
The same algorithms used by Mathematica, SageMath, and research-grade CAS systems — implemented from scratch in pure Python.
- Primality — Miller-Rabin, Baillie-PSW, Lucas-Lehmer
- Factorization — Brent's variant of Pollard's rho, Lenstra's ECM (Elliptic Curve Method), Self-Initializing Quadratic Sieve with up to 3 large primes
- Prime counting — Lagarias-Miller-Odlyzko combinatorial method
- Discrete log — Pohlig-Hellman, Baby-step giant-step, Pollard rho
- Modular roots — Tonelli-Shanks, Adleman-Manders-Miller for arbitary k-th roots, Hensel lifting with both simple and multiple roots
- Diophantine — Cornacchia, Pell solver, binary quadratic forms, Pillai's equation
- Lattices — LLL reduction, Babai's nearest plane, Smith normal form
Documentation
See API.md for the full API reference.
Requirements
Python 3.10+
That's it.
License
Free to use, copy, modify, and redistribute with attribution.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file numthy-0.1.0b0.tar.gz.
File metadata
- Download URL: numthy-0.1.0b0.tar.gz
- Upload date:
- Size: 106.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8648bad2cf7bb42af26bd89206abe54b0caeb570248a999c8f264651e38c15d
|
|
| MD5 |
3ee3de0e82b199f475197b8635d4e673
|
|
| BLAKE2b-256 |
373ee416eb4432930b6ad8c09ec5c895ad776a07a5576e1a507703efa4106623
|
File details
Details for the file numthy-0.1.0b0-py3-none-any.whl.
File metadata
- Download URL: numthy-0.1.0b0-py3-none-any.whl
- Upload date:
- Size: 62.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50f6543fb643f220f60e0c05ed04f95ea1d01c92f2a646db2ee6fd843c56bd95
|
|
| MD5 |
93445723fcee68be07d027d29cf61411
|
|
| BLAKE2b-256 |
5c515b87803d54481280055c840f778089d921b3bf33b9ff84995837792e6b5b
|