diff options
author | Rasmus Villemoes <rasmus.villemoes@prevas.dk> | 2022-04-27 12:07:20 +0200 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2022-05-09 14:38:01 +0100 |
commit | f45ab30c0b627099fedf57946a469f8d29a32915 (patch) | |
tree | 8a0a2af97d37e8ea2eb66cbd588102765ab30060 /doc | |
parent | ddafdae21c574b1dcd5c56e403c82010e7ed3565 (diff) | |
download | coreutils-f45ab30c0b627099fedf57946a469f8d29a32915.tar.gz |
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 <emanuel.landeholm@gmail.com>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/coreutils.texi | 24 |
1 files changed, 14 insertions, 10 deletions
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 |