Skip to main content

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


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)

Uploaded Source

Built Distribution

number_utils-0.0.2-py3-none-any.whl (5.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page