A representation of rational numbers as lists of prime powers, allowing efficient representation, multiplication and division of large numbers, especially of the sort occurring in combinatorial computations.
The module also includes a method for generating factorials in factored form directly, and for computing Euler's totient and generating all divisors of factored integers.
The type of factored rationals.
Instances are provided for Eq, Ord, Additive, Ring, ZeroTestable, Real, ToRational, Integral, RealIntegral, ToInteger, and Field.
Note that currently, addition is performed on factored rationals by converting them to normal rationals, performing the addition, and factoring. This could probably be made more efficient by finding a common denominator, pulling out common factors from the numerators, and performing the addition and factoring only on the relatively prime parts.
Compute Euler's totient function (
eulerPhi n is the number of
integers less than and relatively prime to n). Only makes sense
for (nonnegative) integers.