nzmath.factor.misc

FactoredInteger

Integers with factorization information.
(new in 0.91.0)

Constructors

FactoredInteger(integer [, factors])

If factors is given, it is a dict of type {prime:exponent} and the product of prime**exponent is equal to the integer. Otherwise, factorization is carried out in initialization.

FactoredInteger.from_partial_factorization(integer, partial)

A class method constructs a new FactoredInteger object from partial factorization information given as dict of type {prime:exponent}.

Methods

is_divisible_by(other)

Return True if other divides self. other can be FactoredInteger object or int/long.

exact_division(other)

Divide by other. The other must divide self. other can be FactoredInteger object or int/long.

divisors()

Return all divisors.

proper_divisors()

Return the proper divisors (divisors of n excluding 1 and n).

prime_divisors()

Return the list of primes that divides the number.

square_part([asfactored])

Return the largest integer whose square divides the number.

If an optional argument asfactored is true, then the result is also a FactoredInteger object. (default is False)

squarefree_part([asfactored])

Return the largest divisor of the number which is squarefree.

If an optional argument asfactored is true, then the result is also a FactoredInteger object. (default is False)

copy()

Return a copy of the object.

Operators

operatordescription
*multiplication (other operand can be an int)
**powering
==equal
!=not equal
%remainder (the result is an int)
//same as exact_division method
strstring
int, longconvert to Python integer