Overview
factor breaks a whole number into its prime factors, and prints the number, a colon and the factors. Without arguments it reads numbers from standard input, one per line. It is mostly a curiosity, but it is quick for checking whether a number is prime.
Background
factor is part of GNU coreutils and is also an applet in BusyBox. macOS does not ship it. They agree on the output format N: p1 p2 ....
Examples
Factor a number:
factor 12
Factor several numbers at once:
factor 12 17
Read the numbers from standard input:
echo 30 | factor
Check whether a number is prime: a prime has exactly one factor, itself:
factor 17 | awk '{print NF - 1}'
Common mistakes
A prime prints as 17: 17, which is easy to read as a mistake. Very large numbers can take a long time, and the limit differs between implementations. factor accepts only non-negative whole numbers.
Portability
This page has no Apple view: macOS has no factor. The Common examples were executed on GNU coreutils 9.11 and BusyBox 1.37.0 (see the development guide for the exact check).
About BusyBox factor
BusyBox bundles factor as an applet, and anything beyond the common options depends on how it was built. This page's examples ran on BusyBox 1.37.0.
BusyBox notes
BusyBox factor supports the options used in the Common examples. Others, and GNU long options, depend on the build.
References
Original explanations, with upstream documentation for further reading. FreeBSD references are comparison material, not a claim of Apple version equivalence.