summaryrefslogtreecommitdiffstats
path: root/factor/factor.c
Commit message (Collapse)AuthorAgeFilesLines
* - remove duplicate commentchristos2020-10-121-3/+3
| | | | - flush after printing the number (from kre@)
* Remove is_hex_str() (trying to guess if a number was hex or not). It is notchristos2020-10-111-27/+3
| | | documented and can lead to unexpected behavior.
* From gson@christos2020-10-111-31/+42
| | | | - don't assume -h is always on for large factors - fix saved large factors printing when -h
* - for readability when the exponent < 10 don't prefix it with 0x (from kre)christos2020-10-071-8/+19
| | | | - fix usage - merge printing code.
* PR/55695: Andreas Gustafsson: factor(6) -h option doesn't always workchristos2020-10-051-3/+41
| | | Handle -h for factors greater than the primes table.
* revert previous and don't parse octalchristos2020-10-051-7/+4
|
* factor: usage(): mark __deadtnn2020-10-051-3/+3
|
* - Accept octal input.christos2020-10-041-5/+6
| | | - Don't play with the original string so we can print it.
* PR/55693: Andreas Gustafsson: factor(6) lists factors in wrong orderchristos2020-10-031-185/+224
| | | | Sync with FreeBSD and change their -h (that printed hex) to -x because we were already using -h.
* fix for OpenSSL-1.1christos2018-02-061-8/+8
|
* Add -h option to factor(6): duplicate factors are printed inrin2017-11-111-15/+35
| | | "human-readable" form of x^n.
* Imported and adapted from FreeBSD svn r272166 and r272207; this fixesast2014-10-021-9/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* remove duplicated #defines (in a usually unused part of the code)drochner2011-11-091-5/+2
|
* Properly print string.joerg2011-05-231-3/+3
|
* Follow the Fundamental Theory of Algebra. Disallow factorising ofjoerg2010-05-151-9/+5
| | | | | | | | numbers less than 2 as it is not - naturally unique (negative numbers) - finite (0) - non-empty (1) Discussed with the kristaps and wiz
* cast isblank(3)'s argument to unsigned char.tnozaki2010-05-131-3/+3
|
* rename pollard_pminus1->pollard_rho for consistencydrochner2010-04-281-8/+6
|
* -Fix an old bug in the "pollard" code: it gets its argument passeddrochner2010-04-271-28/+59
| | | | | | | | | | | | 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.
* fix an obvious flaw in bounds check: the array of precomputed primesdrochner2010-04-221-4/+5
| | | | | 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)
* sprinkle staticdholland2009-08-121-16/+15
|
* Remove the \n and tabs from the __COPYRIGHT() strings.lukem2008-07-201-4/+4
|
* convert __attribute__s to applicable cdefs.h macrosperry2007-12-151-3/+3
|
* Fixed a comment that said the factors in the output would be strictlyrillig2005-06-271-3/+3
| | | ascending.
* Check large factor for being prime before applying Pollard'sjsm2004-02-081-6/+14
| | | | | | 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>.
* Move UCB-licensed code from 4-clause to 3-clause licence.agc2003-08-071-7/+3
| | | Patches provided by Joel Baker in PR 22269, verified by myself.
* Provide a BN_dec2bn() shim for the non-openssl case that reports an errorsimonb2002-06-181-3/+21
| | | if strtoul() fails.
* Fix a logic botch where if a number smaller than the square of the seivesimonb2002-06-171-12/+25
| | | | | | | | 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...
* make factor work with and without openssl.itojun2002-06-161-3/+46
|
* Use libcrypto's bignum support to implement a Pollard Rho factoringsimonb2002-06-151-39/+108
| | | algorithm so we can factorise numbers larger than a host long.
* Add use of `const' where appropriate to the games.jsm1999-09-081-5/+5
| | | | | | | | | 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.
* mark non-returning functions (PR#6144 by Joseph Myers <jsm28@cam.ac.uk>)hubertf1998-09-131-3/+3
|
* WARNSifylukem1997-10-101-6/+7
|
* Sync to 4.4BSD-Lite2tls1997-01-071-3/+4
|
* merge with Lite, new RCS id conventions, etc.cgd1995-03-231-236/+95
|
* bring in limits.hderaadt1994-03-031-1/+2
|
* Eliminate a compiler warning.mycroft1993-12-081-2/+2
|
* Add RCS identifiers.mycroft1993-08-011-1/+2
|
* initial import of 386bsd-0.1 sourcescgd1993-03-211-0/+346