Test and find prime numbers
Project description
Pseudoprimes
Test and find prime numbers.
>>> import pseudoprimes
>>> pseudoprimes.is_prime(11)
True
>>> pseudoprimes.is_prime(1022117) # 1009*1013
False
>>> pseudoprimes.get_prime(128) # 128-bit prime
181872728983755108091298489166590324849
>>> pseudoprimes.next_prime(3)
5
>>> pseudoprimes.prev_prime(100)
97
Installation
pip install pseudoprimes
Probabilistic or deterministic?
The used Miller–Rabin primality test^1 is deterministic until ~3.3 * 10^24[^2] (or ~1.37 * 2^81). Numbers larger than that are tested using a probabilistic Baillie–PSW primality test[^3]. While there are no known composite numbers that pass the test, it's believed they exist.
[^2]: The exact number is 3,317,044,064,679,887,385,961,981 https://oeis.org/A014233 [^3]: https://en.wikipedia.org/wiki/Baillie%E2%80%93PSW_primality_test
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 pseudoprimes-2022.5.1.tar.gz.
File metadata
- Download URL: pseudoprimes-2022.5.1.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca25b7b50b5f639062feabda55ecee626af46f9ad5c47abe6f78fd4c302a1866
|
|
| MD5 |
76d919e704ec21e5bbe111613f1764b8
|
|
| BLAKE2b-256 |
137bc0991d1a25ec661b75af33fd871067f47e6c7adb9323d2b8b87f4f410035
|
File details
Details for the file pseudoprimes-2022.5.1-py3-none-any.whl.
File metadata
- Download URL: pseudoprimes-2022.5.1-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca8bd80c2d58e59f39a1618184116c9fce54799cbbfc191a997d40f4e47e4ead
|
|
| MD5 |
ce3157e57f788adc72207b504e159b37
|
|
| BLAKE2b-256 |
fc391067803ca409236b11f9462014993da347b2b6f1b4346c35664ce3f7ebda
|