Home | History | Annotate | Download | only in primes
History log of /src/games/primes/primes.c
RevisionDateAuthorComments
 1.22  03-Feb-2018  christos PR/52976: Eitan Adler: handle larger primes
Using results from
J. Sorenson and J. Webster, Strong pseudoprimes to twelve prime
bases, Math. Comp. 86(304):985-1003, 2017.
teach primes(6) to enumerate primes up to 2^64 - 1. Until Sorenson
and Webster's paper, we did not know how many strong speudoprime tests
were required when testing alleged primes between 3825123056546413051
and 2^64 - 1.

Adapted from: FreeBSD
 1.21  04-Oct-2014  wiz usage police
 1.20  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.19  30-Aug-2011  jakllsch branches: 1.19.20;
No need to cast double to ubig (aka uintmax_t) through int.

This change prevents a modulo by zero in a invocation such as:
primes 18446744073709551000 18446744073709551615
on a LP64 machine.
 1.18  13-May-2010  tnozaki cast isblank(3)'s argument to unsigned char.
 1.17  12-Aug-2009  dholland sprinkle static
 1.16  20-Jul-2008  lukem Remove the \n and tabs from the __COPYRIGHT() strings.
 1.15  02-Feb-2008  matt branches: 1.15.6;
Add a -d flag so that primes will print the difference between the current
prime and the previous prime. [I needed that for some reason I don't recall
and these changes lying about. Since they might be useful/interesting to
someone, I might as well as commit them.]
 1.14  02-Feb-2008  matt Fix typo: sive -> sieve.
 1.13  15-Dec-2007  perry convert __attribute__s to applicable cdefs.h macros
 1.12  27-Jan-2004  jsm branches: 1.12.22;
Remove uses of __P.
 1.11  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.10  20-Jan-2001  itojun avoid strange typcast.
 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  12-Oct-1997  lukem WARNSify
 1.6  07-Jan-1997  tls Sync to 4.4BSD-Lite2
 1.5  24-Apr-1995  cgd Various changes to make games compile w/o warnings on the alpha:
Include appropriate includes, delete bogus function declarations,
change sizes of variables and casts.
 1.4  23-Mar-1995  cgd merge with Lite, new RCS id conventions, etc.
 1.3  01-Mar-1994  cgd bin/144: patch from Arne Juul <arnej@dsl.unit.no> to deal with big
numbers
 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.12.22.2  23-Mar-2008  matt sync with HEAD
 1.12.22.1  09-Jan-2008  matt sync with HEAD
 1.15.6.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.19.20.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