polymerist.maths.primes

Utilities for examining prime numbers and integer factorizations

Attributes

Factorization

Functions

is_prime(→ bool)

Check if an integer is prime

is_prime_alt(→ bool)

Check if an integer is prime

prime_factorization(→ Factorization)

Computes prime factorization of an integer n. Returns factorization as a dict,

num_from_factorization(→ int)

Reconstruct a number as a composition of its factors

Module Contents

type polymerist.maths.primes.Factorization = dict[int, int]
polymerist.maths.primes.is_prime(n: int) bool[source]

Check if an integer is prime

polymerist.maths.primes.is_prime_alt(n: int) bool[source]

Check if an integer is prime

polymerist.maths.primes.prime_factorization(n: int) Factorization[source]

Computes prime factorization of an integer n. Returns factorization as a dict, where the keys are the prime factors and the values are their respective exponents

polymerist.maths.primes.num_from_factorization(fac: Factorization) int[source]

Reconstruct a number as a composition of its factors