Hi, this is Sandra Henry-Stocker, author of the “Unix as a Second Language” blog on NetworkWorld.
In this Linux tip, we’re going to look at the factor command. It’s not one that you will likely need very often, but it can be very useful when you’re doing math on the command line. Just as the name implies, it provides the factors for any number you offer as an argument.
In case you haven’t thought about factors in a while, they are the prime numbers that multiplied produce the number you’re starting with. A prime number is a whole number greater than one that cannot be the result of multiplying other whole numbers.
Here’s an example:
$ factor 123
123: 3 41
$ factor 123456789
123456789: 3 3 3607 3803
The factors for 123 are 3 and 41. The factors for 123,456,789 are 3, 3, 3607 and 3803. Each of these numbers is prime. If you try to factor a number which is prime, you get nothing but the number itself.
$ factor 3803
3803: 3803
Factoring has many applications in the real world and being able to factor on the Linux command line can be very useful.
That’s your Linux tip for the factor command.
If you have questions or would like to suggest a topic, please add a comment below. And don’t forget to subscribe to the IDG Tech(talk) channel on YouTube.
If you liked this video, please hit the like and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and NetworkWorld.com.