Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to get prime factor of some integer numbers by using command-line.


An Integer number 786 has (prime) factors:
2, 3 and 131

Other example for 1234567890 is :
2, 3 (two times), 5, 3607 and 3803.

How do I get such above result using simple command?

share|improve this question
up vote 4 down vote accepted

There is factor command available as follows:

       factor - factor numbers

       factor [NUMBER]...

       Print  the  prime  factors  of  each specified integer NUMBER.  If none are specified on the command line, read them from
       standard input.


$ factor 786
786: 2 3 131

$ factor 1234567890
1234567890: 2 3 3 5 3607 3803

Visit : man factor.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.