Linux factor Command

factor command in linux print the prime factors of each specified integer number. If none are specified on the command line, factor command will read them from standard input.

Introduction

factor command in Linux print the prime factors of each specified integer number. If none are specified on the command line, the factor command will read them from standard input.

factor is part of GNU Coreutils package.

factor Syntax


factor [NUMBER]...
factor OPTION

Getting prime factor of a number

We can pass the number directly to factor as input to be calculated.


$ factor 100
100: 2 2 5 5

$ factor 10
10: 2 5

$ factor 50
50: 2 5 5

Factor command without input

If we run factor without input it will ask for input from standard input. For example:


$ factor
10
10: 2 5
20
20: 2 2 5
30
30: 2 3 5
40
40: 2 2 2 5
50
50: 2 5 5
100
100: 2 2 5 5
1000
1000: 2 2 2 5 5 5

Getting factor help

To get help of factor command we can use --help option.

factor --help
Usage: factor [NUMBER]...
  or:  factor OPTION
Print the prime factors of each specified integer NUMBER.  If none
are specified on the command line, read them from standard input.

      --help     display this help and exit
      --version  output version information and exit

GNU coreutils online help: 
Report factor translation bugs to 
Full documentation at: 
or available locally via: info '(coreutils) factor invocation'

Check factor version

To check factor version we can use --version command.

factor --version
factor (GNU coreutils) 8.30
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Paul Rubin, Torbjörn Granlund, and Niels Möller.

Linux factor Command Source Code

You can find factor command source code from the folowing repositories:

Summary

In this tutorial we learn how to use factor in Linux with practical examples. Visit our Linux Commands guide to learn more about using command line interface in Linux.