A simple collection of prime number related functions.
Project description
PyPrimer
A simple collection of prime number related functions.
Install
$ pip install pyprimer
For bleeding edge
$ pip install git+https://github.com/mentix02/pyprimer
Docs
is_prime(int) -> bool
- Checks if given number n is prime.
>>> from pyprimer import is_prime
>>> is_prime(3)
True
primes_till(int) -> List[int]
- Returns a list of all primes numbers up until n.
>>> from pyprimer import primes_till
>>> primes_till(6)
[2, 3, 5, 7]
n_primes(int) -> List[int]
- Returns a list of first n natural primes numbers.
>>> from pyprimer import n_primes
>>> n_primes(6)
[2, 3, 5, 7, 11, 13]
n_prime(int) -> int
- Returns the nth prime number.
>>> from pyprimer import n_prime
>>> n_prime(13)
41
prime_generator() -> Iterator[int]
- Returns an iterable of ints with each next element being the next prime number.
>>> from pyprimer import prime_generator
>>> total = 0
>>> g = prime_generator()
>>> for n in g:
... if n == 13:
... break
... total += n
>>> print(total)
28
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
pyprimer-0.1.0.tar.gz
(2.0 kB
view details)
Built Distribution
File details
Details for the file pyprimer-0.1.0.tar.gz
.
File metadata
- Download URL: pyprimer-0.1.0.tar.gz
- Upload date:
- Size: 2.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 865d9cf6de71f13cfb8c971150b0d9ea82d783b70eb146f43afce8ec51070d7b |
|
MD5 | 8ff3854dea156a2089f9c115f3d75416 |
|
BLAKE2b-256 | 1c81c7ec7aa21751095c0a8ab699c8089f8075212b0bdbc8b70de3355c4e5de1 |
File details
Details for the file pyprimer-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pyprimer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81bbd8d36b04d944d5d3f50a3cbf30e2596f8fdc834d1e18d882c4aba443b52a |
|
MD5 | 65eed7bac600135bd1123a76a9651a2c |
|
BLAKE2b-256 | 52828b4bf5da0fee7c88c88001cd5ab53fd39b3ba186abc7923fb9d7f543b5c1 |