PrimeFactors |
Top Previous Next |
primefactors(a, separate(optional))
Returns a list value that contains the prime factors of a. The result of this function is normally place
$p = primefactors(75) = 3, 5:2
The factors can be accessed individually using references
$p[1] = 3 $p[2] = 5:2
The notation 5:2 indicates that the factor 5 occurs with a frequency of 2 (5^2). You can access the data value and the frequency separately using the datavalue and freq commands.
{datavalue($p[2])} = 5 {freq($p[2])} = 2
Adding a non-zero second parameter tells the primefactor command to separate out repeated factors instead of using frequencies.
primefactors(75,1) = 3, 5, 5
|