From f45ab30c0b627099fedf57946a469f8d29a32915 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Wed, 27 Apr 2022 12:07:20 +0200 Subject: factor: --exponents: new option for printing in p^e format When factoring numbers that have a large 2^n factor, it can be hard to eyeball just how many 2's there are. Add an option to print each prime power factor in the p^e format (omitting the exponent when it is 1). * src/factor.c: Add -h, --exponents option for printing in p^e format. * doc/coreutils.texi (factor invocation): Document the new option. * tests/misc/factor.pl: Add test case. * THANKS.in: Add previous suggester (https://lists.gnu.org/r/coreutils/2017-11/msg00015.html). Suggested-by: Emanuel Landeholm Signed-off-by: Rasmus Villemoes --- doc/coreutils.texi | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'doc') diff --git a/doc/coreutils.texi b/doc/coreutils.texi index b1ec7c61c..7bca37b71 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -18619,26 +18619,30 @@ These programs do numerically-related operations. @pindex factor @cindex prime factors -@command{factor} prints prime factors. Synopses: +@command{factor} prints prime factors. Synopsis: @example -factor [@var{number}]@dots{} -factor @var{option} +factor [@var{option}]@dots{} [@var{number}]@dots{} @end example If no @var{number} is specified on the command line, @command{factor} reads numbers from standard input, delimited by newlines, tabs, or spaces. -The @command{factor} command supports only a small number of options: +The program accepts the following options. Also see @ref{Common options}. @table @samp -@item --help -Print a short help on standard output, then exit without further -processing. +@item -h +@itemx --exponents +@opindex -h +@opindex --exponents +print factors in the form @math{p^e}, rather than repeating +the prime @samp{p}, @samp{e} times. If the exponent @samp{e} is 1, +then it is omitted. -@item --version -Print the program version on standard output, then exit without further -processing. +@example +$ factor --exponents 3000 +3000: 2^3 3 5^3 +@end example @end table If the number to be factored is small (less than @math{2^{127}} on -- cgit v1.2.1