arctans.primes

Mathematical utility functions.

Attributes

primes

Functions

pfactors(→ list[arctans.numbers.Integer])

Get list of all prime factors of n.

largest_pfactor(→ arctans.numbers.Integer)

Compute the largest prime factor of n.

is_prime(→ bool)

Check if an integer is prime.

is_irreducible(→ bool)

Check if arctan(n) is irreducible.

is_gaussian_prime(→ bool)

Check if n is a Gaussian prime.

is_gaussian_unit(→ bool)

Check if n is a Gaussian unit.

complex_factorise(→ list[arctans.numbers.GaussianInteger])

Factorise a Gaussian integer into Gaussian primes.

Module Contents

arctans.primes.primes = [2]
arctans.primes.pfactors(n: int) list[arctans.numbers.Integer]

Get list of all prime factors of n.

Parameters:

n – An integer

Returns:

A list of the prime factors of n, including factors multiple times when they appear more than once in the prime factorisation

arctans.primes.largest_pfactor(n: int | arctans.numbers.Integer) arctans.numbers.Integer

Compute the largest prime factor of n.

Parameters:

n – An integer

Returns:

The largest prime factor of n

arctans.primes.is_prime(n: arctans.numbers.Integer | int) bool

Check if an integer is prime.

Parameters:

n – An integer

Returns:

True if n is prime

arctans.primes.is_irreducible(n: arctans.numbers.Integer | int) bool

Check if arctan(n) is irreducible.

An arctan is irreducible iff it cannot be written as a weighted sum of integer arccotangents, or equivalently arctan(n) is irreducible iff the largest prime factor of 1 + n**2 is greater than or equal to 2*n.

Parameters:

n – An integer

Returns:

True if n is irreducible

arctans.primes.is_gaussian_prime(n: arctans.numbers.GaussianInteger) bool

Check if n is a Gaussian prime.

Parameters:

n – An integer

Returns:

True if n is a Gaussian prime

arctans.primes.is_gaussian_unit(n: arctans.numbers.GaussianInteger) bool

Check if n is a Gaussian unit.

Parameters:

n – An integer

Returns:

True if n is 1, -1, i or -i

arctans.primes.complex_factorise(n: arctans.numbers.GaussianInteger, istart: int = 0) list[arctans.numbers.GaussianInteger]

Factorise a Gaussian integer into Gaussian primes.

Parameters:

n – An integer

Returns:

A list of Gaussian primes