Safe Haskell | None |
---|

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 generating all divisors of factored integers, or computing Euler's totient (phi) function and the Möbius (mu) function.

# Type

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.