Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

Example:

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

1 Answer 1

up vote 4 down vote accepted

There is factor command available as follows:

NAME
       factor - factor numbers

SYNOPSIS
       factor [NUMBER]...

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

Example:

$ factor 786
786: 2 3 131

$ factor 1234567890
1234567890: 2 3 3 5 3607 3803

Visit : man factor.

share|improve this answer

Your Answer

 
discard

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.