Is there a practical use for the GNU factor command?

Wikipedia, "Factor (Unix)" with an interesting take:

factor first appeared on 5th edition Research Unix in 1974, as a "user maintained" utility (section 6 of the manual). In the 7th edition in 1979, it was moved into the main "commands" section of the manual (section 1). From there, the factor utility was copied to all other variants of Unix, including commercial Unixes and BSD. In some variants of Unix, it is classified as a "game" more than a serious utility, and therefore documented in section 6.

So it would seem that some user(s) liked to play around with prime factors and wrote factor - and once it existed, there probably was no good reason not to include it as a command in subsequent Unix versions. So the "practical uses" of factor may depend on what you consider practical - if you are into prime number theory, it is probably a great tool/game/whatever.


I know that in at least one case, for me factor was helpful in the analysis of a large data file of unknown format.

If you suspect a file has fixed length records, the prime factors of the file's length provide a starting point from which to determine the actual record length.


It will tell you what prime numbers can be multiplied together to get the number you've specified:

e.g 20 = 2 * 2 * 5

So,

> factor 20

You get 20: 2 2 5 as output

If the number was a prime, e.g 19, you will get a 19 only.