← 返回命令列表

Linux command

factor 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Factorize a number

factor [12]

Factorize multiple numbers

factor [12] [100] [256]

Read numbers from stdin

echo "[123456]" | factor

Factorize numbers interactively

factor

Factorize a large number

factor [9999999999999999999999]

Show prime factors using exponent notation

factor -h [1024]

说明

factor prints the prime factors of each specified integer. For each input number, it outputs the number followed by a colon and its prime factors in ascending order, with repeated factors shown multiple times. For example, factor 12 outputs 12: 2 2 3 because 12 = 2 × 2 × 3. Prime numbers return themselves as the only factor. The number 1 has no prime factors and returns just 1:. When called without arguments, factor enters interactive mode, reading numbers from stdin one per line. This is useful for factoring many numbers or integrating with pipes. The implementation uses trial division for small factors and Pollard's rho algorithm for larger numbers. GNU coreutils factor can handle arbitrarily large numbers when built with GNU MP support, while some implementations have size limits. Common uses include mathematical exploration, cryptography education, number theory problems, and verifying primality (a prime number has only itself as a factor).

参数

-h, --exponents
Print factors in the form p^e instead of repeating prime p e times. If the exponent e is 1, it is omitted.
--help
Display help information and exit.
--version
Display version information and exit.

FAQ

What is the factor command used for?

factor prints the prime factors of each specified integer. For each input number, it outputs the number followed by a colon and its prime factors in ascending order, with repeated factors shown multiple times. For example, factor 12 outputs 12: 2 2 3 because 12 = 2 × 2 × 3. Prime numbers return themselves as the only factor. The number 1 has no prime factors and returns just 1:. When called without arguments, factor enters interactive mode, reading numbers from stdin one per line. This is useful for factoring many numbers or integrating with pipes. The implementation uses trial division for small factors and Pollard's rho algorithm for larger numbers. GNU coreutils factor can handle arbitrarily large numbers when built with GNU MP support, while some implementations have size limits. Common uses include mathematical exploration, cryptography education, number theory problems, and verifying primality (a prime number has only itself as a factor).

How do I run a basic factor example?

Run `factor [12]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -h, --exponents do in factor?

Print factors in the form p^e instead of repeating prime p e times. If the exponent e is 1, it is omitted.