xref: /illumos-gate/usr/src/man/man1/factor.1 (revision eb6b10e69fa5ba733da194d3ad71a0e63338be29)
te
Copyright 1989 AT&T Copyright (c) 1996, Sun Microsystems, Inc. All Rights Reserved
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
FACTOR 1 "Jan 31, 1996"
NAME
factor - obtain the prime factors of a number
SYNOPSIS

factor [integer]
DESCRIPTION

factor writes to standard input all prime factors for any positive integer less than or equal to 10^14. The prime factors are written the proper number of times.

If factor is used without an argument, it waits for an integer to be entered. After entry of the integer, it factors it, writes its prime factors the proper number of times, and then waits for another integer. factor exits if a 0 or any non-numeric character is entered.

If factor is invoked with an argument (integer), it writes the integer, factors it and writes all the prime factors as described above, and then exits. If the argument is 0 or non-numeric, factor writes a 0 and then exits.

The maximum time to factor an integer is proportional to sqrt(n), where n is the integer which is entered. factor will take this time when n is prime or the square of a prime.

OPERANDS
integer

Any positive integer less than or equal to 10^14.

EXIT STATUS
0

Successful completion.

1

An error occurred.

DIAGNOSTICS

factor prints the error message Ouch! for input out of range or for garbage input.

SEE ALSO

attributes(5)