A library of functions related to prime numbers.
Project description
number-utils
A library to perform various operations on prime numbers.
Installation
pip install number-utils
Usage
>>> import number_utils
>>> dir(number_utils)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__',
'__package__', '__path__', '__spec__', 'are_mutually_prime', 'factor_pairs', 'factors',
'highest_power', 'is_prime', 'mutually_prime_factor_pairs', 'number_of_divisors',
'number_of_factor_pairs', 'number_of_mutually_prime_factor_pairs', 'prime_factorise',
'prime_factors', 'prime_over', 'prime_under', 'primes', 'primes_between', 'primes_under',
'sum_of_divisors']
>>>
>>> # Examples
>>> from number_utils import is_prime, are_mutually_prime, prime_factorise
>>> is_prime(101)
True
>>> are_mutually_prime(24, 77)
True
>>> prime_factorise(21600, show=True)
2^5 * 3^3 * 5^2
[(2, 5), (3, 3), (5, 2)]
>>>
>>> help(prime_factorise)
Help on function prime_factorise in module number_utils.primes:
prime_factorise(n, show=False)
Prime factorisation.
If `show` is True, print an expression of the form:
a^p * b^q * c^r
where a, b, c, etc. are prime factors of n and p, q, r, etc. are
their powers.
Return a list of tuples of prime factor and power.
>>>
>>> help(number_utils.highest_power)
Help on function highest_power in module number_utils.primes:
highest_power(m: int, n: int)
Highest power of a prime m in n!
Formula: Sum of greatest integers contained in (n / m^i), where i
is 1, 2, 3, etc.
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
number-utils-0.0.2.tar.gz
(3.8 kB
view details)
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 number-utils-0.0.2.tar.gz.
File metadata
- Download URL: number-utils-0.0.2.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c9c17f5c97fdb94ff52cd4902fc458810e5ae9d42001a7a80ebabf54d6fafb7
|
|
| MD5 |
ed91fad144472462e404a4ee8ebe98f2
|
|
| BLAKE2b-256 |
74e6fd481c2fa4e46f06de5ed84dbaf5d19b6ca6a28073121c270a707303a5f0
|
File details
Details for the file number_utils-0.0.2-py3-none-any.whl.
File metadata
- Download URL: number_utils-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b9ea2e6ad0b00fb3adae90c944028dad88967e61a290bb5e8941653493bb288
|
|
| MD5 |
68b7101d8789147300d419debe5956b1
|
|
| BLAKE2b-256 |
db9535aa06cd4728a587af6395bea8756ed956dc74683966d5ba5aea9eeca51a
|