xref: /minix3/games/factor/factor.6 (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc.\"	$NetBSD: factor.6,v 1.13 2014/10/02 21:36:37 ast Exp $
2c1f592a2SThomas Cort.\"
3c1f592a2SThomas Cort.\" Copyright (c) 1989, 1993
4c1f592a2SThomas Cort.\"	The Regents of the University of California.  All rights reserved.
5c1f592a2SThomas Cort.\"
6c1f592a2SThomas Cort.\" This code is derived from software contributed to Berkeley by
7c1f592a2SThomas Cort.\" Landon Curt Noll.
8c1f592a2SThomas Cort.\"
9c1f592a2SThomas Cort.\" Redistribution and use in source and binary forms, with or without
10c1f592a2SThomas Cort.\" modification, are permitted provided that the following conditions
11c1f592a2SThomas Cort.\" are met:
12c1f592a2SThomas Cort.\" 1. Redistributions of source code must retain the above copyright
13c1f592a2SThomas Cort.\"    notice, this list of conditions and the following disclaimer.
14c1f592a2SThomas Cort.\" 2. Redistributions in binary form must reproduce the above copyright
15c1f592a2SThomas Cort.\"    notice, this list of conditions and the following disclaimer in the
16c1f592a2SThomas Cort.\"    documentation and/or other materials provided with the distribution.
17c1f592a2SThomas Cort.\" 3. Neither the name of the University nor the names of its contributors
18c1f592a2SThomas Cort.\"    may be used to endorse or promote products derived from this software
19c1f592a2SThomas Cort.\"    without specific prior written permission.
20c1f592a2SThomas Cort.\"
21c1f592a2SThomas Cort.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22c1f592a2SThomas Cort.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23c1f592a2SThomas Cort.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24c1f592a2SThomas Cort.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25c1f592a2SThomas Cort.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26c1f592a2SThomas Cort.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27c1f592a2SThomas Cort.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28c1f592a2SThomas Cort.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29c1f592a2SThomas Cort.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30c1f592a2SThomas Cort.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31c1f592a2SThomas Cort.\" SUCH DAMAGE.
32c1f592a2SThomas Cort.\"
33c1f592a2SThomas Cort.\"	@(#)factor.6	8.1 (Berkeley) 5/31/93
34c1f592a2SThomas Cort.\"
35c1f592a2SThomas Cort.\"
36*0a6a1f1dSLionel Sambuc.\" By Landon Curt Noll, http://www.isthe.com/chongo/index.html /\oo/\
37c1f592a2SThomas Cort.\"
38c1f592a2SThomas Cort.Dd May 15, 2010
39c1f592a2SThomas Cort.Dt FACTOR 6
40c1f592a2SThomas Cort.Os
41c1f592a2SThomas Cort.Sh NAME
42c1f592a2SThomas Cort.Nm factor
43c1f592a2SThomas Cort.Nd factor a number
44c1f592a2SThomas Cort.Sh SYNOPSIS
45c1f592a2SThomas Cort.Nm
46c1f592a2SThomas Cort.Op Ar number ...
47c1f592a2SThomas Cort.Sh DESCRIPTION
48c1f592a2SThomas CortThe
49c1f592a2SThomas Cort.Nm
50c1f592a2SThomas Cortutility factors integers larger than 1.
51c1f592a2SThomas CortWhen a number is factored, it is printed, followed by a
52c1f592a2SThomas Cort.Dq \&: ,
53c1f592a2SThomas Cortand the list of
54c1f592a2SThomas Cort.Pq prime
55c1f592a2SThomas Cortfactors on a single line.
56c1f592a2SThomas CortFactors are listed in ascending order, and are preceded by a space.
57c1f592a2SThomas CortIf a factor divides a value more than once, it will be printed more than once.
58c1f592a2SThomas Cort.Pp
59c1f592a2SThomas CortWhen
60c1f592a2SThomas Cort.Nm
61c1f592a2SThomas Cortis invoked with one or more arguments, each argument will be factored.
62c1f592a2SThomas Cort.Pp
63c1f592a2SThomas CortWhen
64c1f592a2SThomas Cort.Nm
65c1f592a2SThomas Cortis invoked with no arguments,
66c1f592a2SThomas Cort.Nm
67c1f592a2SThomas Cortreads numbers, one per line, from standard input, until end of file or error.
68c1f592a2SThomas CortLeading white-space and empty lines are ignored.
69c1f592a2SThomas CortNumbers may be preceded by a single +.
70c1f592a2SThomas CortInteger less than 2 are rejected.
71c1f592a2SThomas CortNumbers are terminated by a non-digit character (such as a newline).
72c1f592a2SThomas CortAfter a number is read, it is factored.
73c1f592a2SThomas CortInput lines must not be longer than
74c1f592a2SThomas Cort.Dv LINE_MAX \- 1
75c1f592a2SThomas Cort(currently 2047) characters.
76c1f592a2SThomas Cort.Pp
77c1f592a2SThomas CortBy default,
78c1f592a2SThomas Cort.Nm
79c1f592a2SThomas Cortis compiled against the OpenSSL bignum implementation
80c1f592a2SThomas Cort.Xr openssl_bn 3 ,
81c1f592a2SThomas Cortwhich lets it handle arbitrarily large values.
82c1f592a2SThomas Cort.Pq Note however that very large values can take a very long time to factor.
83c1f592a2SThomas CortIf
84c1f592a2SThomas Cort.Nm
85c1f592a2SThomas Cortis compiled without OpenSSL it is limited to the maximum value of
86c1f592a2SThomas Cort.Vt unsigned long .
87c1f592a2SThomas Cort.Sh DIAGNOSTICS
88c1f592a2SThomas CortOut of range or invalid input results in
89*0a6a1f1dSLionel Sambucan appropriate error message to standard error.
90*0a6a1f1dSLionel Sambuc.Sh AUTHORS
91*0a6a1f1dSLionel SambucOriginally by
92*0a6a1f1dSLionel Sambuc.An Landon Curt Noll .
93