FACTOR(6)

FACTOR(6) | Games Manual | FACTOR(6)

# NAME

`factor` —
factor a number

# SYNOPSIS

`factor` | [`-h`] [number ...]

# DESCRIPTION

The `factor` utility factors integers larger than 1. When a number is factored, it is printed, followed by a “:”, and the list of (prime) factors on a single line. Factors are listed in ascending order, and are preceded by a space. By default, if a factor divides a value more than once, it will be printed more than once.

When `factor` is invoked with one or more number arguments, each argument will be factored.

When `factor` is invoked with no number arguments, `factor` reads numbers, one per line, from standard input, until end of file or error. Leading white-space and empty lines are ignored. Numbers may be preceded by a single +. Integer less than 2 are rejected. Numbers are terminated by a non-digit character (such as a newline). After a number is read, it is factored. Input lines must not be longer than `LINE_MAX - 1` (currently 2047) characters.

By default, `factor` is compiled against the OpenSSL bignum implementation openssl_bn(3), which lets it handle arbitrarily large values. (Note however that very large values can take a very long time to factor.) If `factor` is compiled without OpenSSL it is limited to the maximum value of unsigned long.

The following option is available:

`-h`
  If the `-h` flag is specified, factors will be printed in "human-readable" format. If a factor x divides a value n (>1) times, it will appear as x^n.

# DIAGNOSTICS

Out of range or invalid input results in an appropriate error message to standard error.

# AUTHORS

Originally by Landon Curt Noll.

Nov 12, 2017 | NetBSD 9.5