GNU Info

Info Node: (sh-utils.info)factor invocation

(sh-utils.info)factor invocation


Next: seq invocation Up: Numeric operations
Enter node , (file) or (file)node

`factor': Print prime factors
=============================

   `factor' prints prime factors.  Synopses:

     factor [NUMBER]...
     factor OPTION

   If no NUMBER is specified on the command line, `factor' reads
numbers from standard input, delimited by newlines, tabs, or spaces.

   The only options are `--help' and `--version'.  Note: Common
options.

   The algorithm it uses is not very sophisticated, so for some inputs
`factor' runs for a long time.  The hardest numbers to factor are the
products of large primes.  Factoring the product of the two largest
32-bit prime numbers takes over 10 minutes of CPU time on a 400MHz
Pentium II.

     $ p=`echo '4294967279 * 4294967291'|bc`
     $ factor $p
     18446743979220271189: 4294967279 4294967291

   In contrast, `factor' factors the largest 64-bit number in just over
a tenth of a second:

     $ factor `echo '2^64-1'|bc`
     18446744073709551615: 3 5 17 257 641 65537 6700417


automatically generated by info2www version 1.2.2.9