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 hashes)
Built Distribution
Close
Hashes for number_utils-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b9ea2e6ad0b00fb3adae90c944028dad88967e61a290bb5e8941653493bb288 |
|
MD5 | 68b7101d8789147300d419debe5956b1 |
|
BLAKE2b-256 | db9535aa06cd4728a587af6395bea8756ed956dc74683966d5ba5aea9eeca51a |