Home | History | Annotate | Download | only in factor
History log of /src/games/factor/factor.c
RevisionDateAuthorComments
 1.38  12-Oct-2020  christos - remove duplicate comment
- flush after printing the number
(from kre@)
 1.37  11-Oct-2020  christos Remove is_hex_str() (trying to guess if a number was hex or not). It is not
documented and can lead to unexpected behavior.
 1.36  11-Oct-2020  christos From gson@
- don't assume -h is always on for large factors
- fix saved large factors printing when -h
 1.35  07-Oct-2020  christos - for readability when the exponent < 10 don't prefix it with 0x (from kre)
- fix usage
- merge printing code.
 1.34  05-Oct-2020  christos PR/55695: Andreas Gustafsson: factor(6) -h option doesn't always work
Handle -h for factors greater than the primes table.
 1.33  05-Oct-2020  christos revert previous and don't parse octal
 1.32  05-Oct-2020  tnn factor: usage(): mark __dead
 1.31  04-Oct-2020  christos - Accept octal input.
- Don't play with the original string so we can print it.
 1.30  03-Oct-2020  christos PR/55693: Andreas Gustafsson: factor(6) lists factors in wrong order
Sync with FreeBSD and change their -h (that printed hex) to -x because
we were already using -h.
 1.29  06-Feb-2018  christos fix for OpenSSL-1.1
 1.28  11-Nov-2017  rin Add -h option to factor(6): duplicate factors are printed in
"human-readable" form of x^n.
 1.27  02-Oct-2014  ast Imported and adapted from FreeBSD svn r272166 and r272207; this fixes
false positives for products of primes larger than 2^16. For example,
before this commit:

$ /usr/games/primes 4295360521 4295360522
4295360521
but
$ /usr/games/factor 4295360521
4295360521: 65539 65539

or
$ /usr/games/primes 3825123056546413049 3825123056546413050
3825123056546413049
yet
$ /usr/games/factor 3825123056546413049
3825123056546413049: 165479 23115459100831

or
$ /usr/games/primes 18446744073709551577
18446744073709551577
although
$ /usr/games/factor 18446744073709551577
18446744073709551577: 139646831 132095686967

Incidentally, the above examples show the smallest and largest cases that
were erroneously stated as prime in the range 2^32 .. 3825123056546413049
.. 2^64; the primes(6) program now stops at 3825123056546413050 as
primality tests on larger integers would be by brute force factorization.

In addition, special to the NetBSD version:
. for -d option, skip first difference when start is >65537 as it is incorrect
. corrected usage to mention both the existing -d as well as the new -h option

For original FreeBSD commit message by Colin Percival, see:
http://svnweb.freebsd.org/base?view=revision&revision=272166
 1.26  09-Nov-2011  drochner branches: 1.26.18;
remove duplicated #defines (in a usually unused part of the code)
 1.25  23-May-2011  joerg branches: 1.25.4;
Properly print string.
 1.24  15-May-2010  joerg Follow the Fundamental Theory of Algebra. Disallow factorising of
numbers less than 2 as it is not
- naturally unique (negative numbers)
- finite (0)
- non-empty (1)

Discussed with the kristaps and wiz
 1.23  13-May-2010  tnozaki cast isblank(3)'s argument to unsigned char.
 1.22  28-Apr-2010  drochner rename pollard_pminus1->pollard_rho for consistency
 1.21  27-Apr-2010  drochner -Fix an old bug in the "pollard" code: it gets its argument passed
by reference, and changes the value behind the pointer under some
circumstances (basically if it finds more than 2 different factors).
It also calls itself if it finds a factor which is not considered prime
(by openssl's miller-rabin check) and uses the call argument afterwards.
This doesn't work -- we need to copy the argument into its own storage.
-Modify the code to do the "rho" algorithm as was initially announced.
It takes somewhat longer in rare cases, but still works in cases where
the "p-1" algorithm is unusable. This might fix PR misc/43192
by Luiz Henrique de Figueiredo.
-Add some optional debug support, minor cleanup.
 1.20  22-Apr-2010  drochner fix an obvious flaw in bounds check: the array of precomputed primes
could be overrun if its last entry (65537) was a factor of the input
(this does not affect PR misc/43192 -- the factors are much larger
here: 7742394596501*159455563099482401)
 1.19  12-Aug-2009  dholland sprinkle static
 1.18  20-Jul-2008  lukem Remove the \n and tabs from the __COPYRIGHT() strings.
 1.17  15-Dec-2007  perry branches: 1.17.6;
convert __attribute__s to applicable cdefs.h macros
 1.16  27-Jun-2005  rillig branches: 1.16.10;
Fixed a comment that said the factors in the output would be strictly
ascending.
 1.15  08-Feb-2004  jsm Check large factor for being prime before applying Pollard's
algorithm; fixes "factor 2147483647111311". Correct comment;
algorithm is Pollard p-1, not Pollard rho. Increase base if p-1
algorithm reaches 1; fixes "factor 99999999999991". Testcases from
David A Bagley <bagleyd@tux.org>.
 1.14  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22269, verified by myself.
 1.13  18-Jun-2002  simonb Provide a BN_dec2bn() shim for the non-openssl case that reports an error
if strtoul() fails.
 1.12  17-Jun-2002  simonb Fix a logic botch where if a number smaller than the square of the seive
was prime to still called the Pollard Rho function when it didn't have
to. Problem report by Nathan Williams.

Unfortunately this one can't be picked up by a simple regression test
since the broken way still produced the correct output, but just took
far longer...
 1.11  16-Jun-2002  itojun make factor work with and without openssl.
 1.10  15-Jun-2002  simonb Use libcrypto's bignum support to implement a Pollard Rho factoring
algorithm so we can factorise numbers larger than a host long.
 1.9  08-Sep-1999  jsm Add use of `const' where appropriate to the games.

This merges in all such remaining changes from the Linux port of the
NetBSD games, except in hunt (where substantial changes from OpenBSD
need to be looked at).

Some such changes were previously covered in PRs bin/6041, bin/6146,
bin/6148, bin/6150, bin/6151, bin/6580, bin/6660, bin/7993, bin/7994,
bin/8039, bin/8057 and bin/8093.
 1.8  13-Sep-1998  hubertf mark non-returning functions (PR#6144 by Joseph Myers <jsm28@cam.ac.uk>)
 1.7  10-Oct-1997  lukem WARNSify
 1.6  07-Jan-1997  tls Sync to 4.4BSD-Lite2
 1.5  23-Mar-1995  cgd merge with Lite, new RCS id conventions, etc.
 1.4  03-Mar-1994  deraadt bring in limits.h
 1.3  08-Dec-1993  mycroft Eliminate a compiler warning.
 1.2  01-Aug-1993  mycroft Add RCS identifiers.
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3  28-Dec-1996  tls Import from 4.4BSD-Lite2
 1.1.1.2  21-Mar-1995  cgd from Lite
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.16.10.1  09-Jan-2008  matt sync with HEAD
 1.17.6.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.25.4.1  10-Nov-2011  yamt sync with head
 1.26.18.1  05-Oct-2014  martin Pull up following revision(s) (requested by ast in ticket #128):
games/primes/pattern.c: revision 1.7
games/primes/primes.h: revision 1.6
games/primes/spsp.c: revision 1.1
games/primes/Makefile: revision 1.8
games/factor/factor.c: revision 1.27
games/factor/factor.6: revision 1.13
games/primes/primes.c: revision 1.20
games/primes/primes.c: revision 1.21
games/primes/pr_tbl.c: revision 1.8
games/primes/primes.6: revision 1.4
games/primes/primes.6: revision 1.5
Imported and adapted from FreeBSD svn r272166 and r272207; this fixes
false positives for products of primes larger than 2^16. For example,
before this commit:
$ /usr/games/primes 4295360521 4295360522
4295360521
but
$ /usr/games/factor 4295360521
4295360521: 65539 65539
or
$ /usr/games/primes 3825123056546413049 3825123056546413050
3825123056546413049
yet
$ /usr/games/factor 3825123056546413049
3825123056546413049: 165479 23115459100831
or
$ /usr/games/primes 18446744073709551577
18446744073709551577
although
$ /usr/games/factor 18446744073709551577
18446744073709551577: 139646831 132095686967
Incidentally, the above examples show the smallest and largest cases that
were erroneously stated as prime in the range 2^32 .. 3825123056546413049
.. 2^64; the primes(6) program now stops at 3825123056546413050 as
primality tests on larger integers would be by brute force factorization.
In addition, special to the NetBSD version:
. for -d option, skip first difference when start is >65537 as it is incorrect
. corrected usage to mention both the existing -d as well as the new -h option
For original FreeBSD commit message by Colin Percival, see:
http://svnweb.freebsd.org/base?view=revision&revision=272166
usage police

RSS XML Feed