Primality helps you easily find, test and work with prime numbers in Python.
Project description
Primality
Primality helps you easily find, test and work with prime numbers in Python.
primality.isprime(516349073509121311)
>> True
primality.nthprime(9999)
>> 104729
primality.prange(10)
>> [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
Installation
Use the package manager pip to install Primality.
pip install primality
Implementation
Primality officially supports Python 3.8+.
from primality import primality
Usage
isprime(p: int) True if {p} is prime.
primality.isprime(13)
>> True
primality.isprime(20)
>> False
primality.isprime(516349073509121311)
>> True
nthprime(nth: int) Returns the {nth} prime, starting from n = 0, returning 2.
primality.nthprime(0)
>> 2
primality.nthprime(100)
>> 547
primality.nthprime(9999)
>> 104729
prange(n: int) Returns a list with the form of [2, 3, ..., {n}th prime].
primality.prange(3)
>> [2, 3, 5]
primality.prange(10)
>> [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
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
primality-0.0.5.tar.gz
(2.6 kB
view hashes)
Built Distribution
Close
Hashes for primality-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2723ede067e81b954ae09a88f3a373a0a652cec1a97e1b698744f371f445b245 |
|
MD5 | 7d2b6258cc5031a6cec6c5e776e420ad |
|
BLAKE2b-256 | 9701957fb1721da7b73737f1e531bbb2db0bbebf8f2ece1cdeb3c417131ea32a |