{
    "mode": "info",
    "parameter": "factor",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/factor/json",
    "generated": "2026-09-16T11:13:39Z",
    "sections": {
        "File: coreutils.info,  Node: factor invocation,  Next: numfmt invocation,  Up: Numeric operations": {
            "content": "",
            "subsections": [
                {
                    "name": "26.1 'factor': Print prime factors",
                    "content": "'factor' prints prime factors.  Synopsis:\n\nfactor [OPTION]... [NUMBER]...\n\nIf no NUMBER is specified on the command line, 'factor' reads numbers\nfrom standard input, delimited by newlines, tabs, or spaces.\n\nThe program accepts the following options.  Also see *note Common\noptions::.\n\n'-h'\n'--exponents'\nprint factors in the form p^e, rather than repeating the prime 'p',\n'e' times.  If the exponent 'e' is 1, then it is omitted.\n\n$ factor --exponents 3000\n3000: 2^3 3 5^3\n\nIf the number to be factored is small (less than 2^{127} on typical\nmachines), 'factor' uses a faster algorithm.  For example, on a\ncirca-2017 Intel Xeon Silver 4116, factoring the product of the eighth\nand ninth Mersenne primes (approximately 2^{92}) takes about 4 ms of CPU\ntime:\n\n$ M8=$(echo 2^31-1 | bc)\n$ M9=$(echo 2^61-1 | bc)\n$ n=$(echo \"$M8 * $M9\" | bc)\n$ bash -c \"time factor $n\"\n4951760154835678088235319297: 2147483647 2305843009213693951\n\nreal\t0m0.004s\nuser\t0m0.004s\nsys\t0m0.000s\n\nFor larger numbers, 'factor' uses a slower algorithm.  On the same\nplatform, factoring the eighth Fermat number 2^{256} + 1 takes about 14\nseconds, and the slower algorithm would have taken about 750 ms to\nfactor 2^{127} - 3 instead of the 50 ms needed by the faster algorithm.\n\nFactoring large numbers is, in general, hard.  The Pollard-Brent rho\nalgorithm used by 'factor' is particularly effective for numbers with\nrelatively small factors.  If you wish to factor large numbers which do\nnot have small factors (for example, numbers which are the product of\ntwo large primes), other methods are far better.\n\nAn exit status of zero indicates success, and a nonzero value\nindicates failure.\n"
                }
            ]
        }
    },
    "flags": [],
    "examples": [],
    "see_also": []
}