Howtodojo logo
  • Home 
  • About 
  • Certifications 
  • Sample Database 
  • Cheatsheet 
  • Glossary 
  • Blog 
  • Tags 
  1.   Linux Commands
  1. Home
  2. Guides
  3. Linux Commands
  4. Linux factor Command

Linux factor Command

Share via
Howtodojo
Link copied to clipboard

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.

On this page
Introduction   factor Syntax   Getting prime factor of a number   Factor command without input   Getting factor help   Check factor version   Linux factor Command Source Code   Summary  

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.c

Linux factor Command Source Code  

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

  • factor source code on GitHub
  • factor source code on GNU Savannah cgit
  • factor source code on GNU Savannah gitweb

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.

 Linux arch Command
Linux whoami Command 
On this page:
Introduction   factor Syntax   Getting prime factor of a number   Factor command without input   Getting factor help   Check factor version   Linux factor Command Source Code   Summary  
Follow me

We publish tutorials, tips and tricks about Linux, open source, cloud computing, and infrastructure

     
Copyright © 2012 - 2025 howtodojo.com. |
Howtodojo
Code copied to clipboard