From 38b4c167efba97445e3dffca780ccab4a3b7937a Mon Sep 17 00:00:00 2001 From: rin Date: Sat, 11 Nov 2017 23:48:44 +0000 Subject: Add -h option to factor(6): duplicate factors are printed in "human-readable" form of x^n. --- factor/factor.6 | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'factor/factor.6') diff --git a/factor/factor.6 b/factor/factor.6 index c36fcb1f..d8c6df26 100644 --- a/factor/factor.6 +++ b/factor/factor.6 @@ -1,4 +1,4 @@ -.\" $NetBSD: factor.6,v 1.13 2014/10/02 21:36:37 ast Exp $ +.\" $NetBSD: factor.6,v 1.14 2017/11/11 23:48:44 rin Exp $ .\" .\" Copyright (c) 1989, 1993 .\" The Regents of the University of California. All rights reserved. @@ -35,7 +35,7 @@ .\" .\" By Landon Curt Noll, http://www.isthe.com/chongo/index.html /\oo/\ .\" -.Dd May 15, 2010 +.Dd Nov 12, 2017 .Dt FACTOR 6 .Os .Sh NAME @@ -43,6 +43,7 @@ .Nd factor a number .Sh SYNOPSIS .Nm +.Op Fl h .Op Ar number ... .Sh DESCRIPTION The @@ -54,15 +55,20 @@ and the list of .Pq prime factors on a single line. Factors are listed in ascending order, and are preceded by a space. -If a factor divides a value more than once, it will be printed more than once. +By default, if a factor divides a value more than once, it will be +printed more than once. .Pp When .Nm -is invoked with one or more arguments, each argument will be factored. +is invoked with one or more +.Ar number +arguments, each argument will be factored. .Pp When .Nm -is invoked with no arguments, +is invoked with no +.Ar number +arguments, .Nm reads numbers, one per line, from standard input, until end of file or error. Leading white-space and empty lines are ignored. @@ -84,6 +90,15 @@ If .Nm is compiled without OpenSSL it is limited to the maximum value of .Vt unsigned long . +.Pp +The following option is available: +.Bl -tag -width flag +.It Fl h +If the +.Fl 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. +.El .Sh DIAGNOSTICS Out of range or invalid input results in an appropriate error message to standard error. -- cgit v1.2.3-56-ge451