Linux Commands

Linux Factor Command Tutorial

In Linux, there is a command-line utility called a very useful factor for those users who work with a prime number.

The product of any prime number generates the original number referred to as Factor.

Factor command in Linux supports us to print prime Factor. For this, we need to enter the number as a parameter with the factor command. If you don’t give any argument, it will read through standard input.

Syntax

$ factor [ Number ]

Non-prime number

Example 1:
First, let’s get the prime Factor, a non-prime number. In my case, I want to find the prime factor of 10 that is a non-prime number.

The number 10 is a product of the prime factors 2 and 5.

Example 2:

The prime factor of 250 is 2 2 5 5.

Multiple prime factors

Pass multiple numbers as an argument to do prime Factor simultaneously.

Prime number

So, let’s do the factorization of 77. The number 77 is the product of combining prime numbers.

The prime number itself

Factorization of 17 would be 17 itself because 17 is a prime number and can’t divide on any other number.

Help Command

Use –help option to view the help message and exit. Type the command given-below to get help:

$ Factor --help

Check version

Use –version or -v option to get the output version information and exit. Check the version as follows:

$ Factor --version

Conclusion

The factor command returns a number’s prime factors. It prints the prime factors for each integer NUMBER. If you don’t pass any argument, it will read from standard input. We did factorization of a particular prime number in this tutorial.

About the author

Aqsa Maqbool

As a Software engineer, I am passionate to write about various IT related
articles but have deep interest in Linux. I spend most of my time reading Linux related blogs and IT related books. I want to serve the world with my writing skills.