5.18 Factors

Factors( r )
Factors( R, r )

In the first form Factors returns the factorization of the ring element r in its default ring (see DefaultRing). In the second form Factors returns the factorization of the ring element r in the ring R. The factorization is returned as a list of primes (see IsPrime). Each element in the list is a standard associate (see StandardAssociate) except the first one, which is multiplied by a unit as necessary to have Product( Factors( R, r ) ) = r. This list is usually also sorted, thus smallest prime factors come first. If r is a unit or zero, Factors( R, r ) = [ r ].

    gap> Factors( -Factorial(6) );
    [ -2, 2, 2, 2, 3, 3, 5 ]
    gap> Set( Factors( Factorial(13)/11 ) );
    [ 2, 3, 5, 7, 13 ]
    gap> Factors( 2^63 - 1 );
    [ 7, 7, 73, 127, 337, 92737, 649657 ]
    gap> Factors( 10^42 + 1 );
    [ 29, 101, 281, 9901, 226549, 121499449, 4458192223320340849 ] 

Factors calls R.operations.Factors( R, r ) and returns the value.

The default function called this way is RingOps.Factors, which just signals an error, because there is no generic way to compute the factorization of ring elements. Thus special categories of ring elements must overlay this default function with other functions.

Previous Up Top Next
Index

GAP 3.4.4
April 1997