LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

factor

prime factorization utility

TLDR

Factorize a number
$ factor [12]
copy
Factorize multiple numbers
$ factor [12] [100] [256]
copy
Read numbers from stdin
$ echo "[123456]" | factor
copy
Factorize numbers interactively
$ factor
copy
Factorize a large number
$ factor [9999999999999999999999]
copy
Show prime factors using exponent notation
$ factor -h [1024]
copy

SYNOPSIS

factor [OPTION] [NUMBER...]

DESCRIPTION

factor prints the prime factors of each specified integer. For each input number, it outputs the number followed by a colon and its prime factors in ascending order, with repeated factors shown multiple times.For example, factor 12 outputs 12: 2 2 3 because 12 = 2 × 2 × 3. Prime numbers return themselves as the only factor. The number 1 has no prime factors and returns just 1:.When called without arguments, factor enters interactive mode, reading numbers from stdin one per line. This is useful for factoring many numbers or integrating with pipes.The implementation uses trial division for small factors and Pollard's rho algorithm for larger numbers. GNU coreutils factor can handle arbitrarily large numbers when built with GNU MP support, while some implementations have size limits.Common uses include mathematical exploration, cryptography education, number theory problems, and verifying primality (a prime number has only itself as a factor).

PARAMETERS

-h, --exponents

Print factors in the form p^e instead of repeating prime p e times. If the exponent e is 1, it is omitted.
--help
Display help information and exit.
--version
Display version information and exit.
NUMBER
One or more integers to factorize. If no numbers are given, reads from stdin.

INSTALL

sudo apt install coreutils
copy
sudo dnf install coreutils
copy
sudo pacman -S coreutils
copy
sudo apk add coreutils
copy
sudo zypper install coreutils
copy
brew install coreutils
copy
nix profile install nixpkgs#coreutils
copy

CAVEATS

Very large numbers take longer to factor. Some implementations have limits on number size. Input must be positive integers. Zero has no prime factorization. Performance for large semiprimes (products of two large primes) is limited by fundamental mathematical constraints.

HISTORY

factor is a classic Unix utility included in Version 1 Unix at Bell Labs in 1971. It has remained part of Unix and Unix-like systems, now included in GNU coreutils. The command is one of the simpler mathematical utilities from Unix's early days, alongside primes which lists prime numbers.

SEE ALSO

primes(6), bc(1), dc(1), expr(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid