Next: i0() Up: Mathematical Macros Help File Previous: factorial()   Contents

factors()

Usage:
factors(vector(n1 [, n2, ...]), positive integer n1, n2, ...



Keywords: prime factors
factors(n), where n > 0 is an integer returns a REAL scalar or vector
containing the prime factors of n.

result <- factors(N), where N = vector(n1,n2,...), integers n1 > 0, n2 >
0, ..., sets result to structure(factor(n1), factor(n2), ...), that is
result[j] contains the factors of N[j].  The name of component j is
'prime' if N[j] is prime and 'composite' otherwise.

Note: factors() has been superceded by function primefactors().

Example:
  Cmd> write(factors(2^2^run(5) + 1),format:"10.0f")
  STRUCTURE:
  component: prime
  (1)          5
  component: prime
  (1)         17
  component: prime
  (1)        257
  component: prime
  (1)      65537
  component: composite
  (1)        641    6700417

See also printfactors() and primefactors().


Gary Oehlert 2003-01-15