Commit Graph

29 Commits

Author SHA1 Message Date
Colin Percival
eb5ea45ba8 Switch primes(6) from using unsigned long to using uint64_t. This fixes
'limited range of type' warnings about comparisons on 32-bit systems, and
allows 32-bit systems to compute the full range of primes.
2014-09-27 09:00:38 +00:00
Colin Percival
535ab8fde8 Correctly enumerate primes between 4295098369 and 3825123056546413050.
Prior to this commit, primes(6) relied solely on sieving with primes up
to 65537, with the effect that composite numbers which are the product
of two non-16-bit primes would be incorrectly identified as prime.  For
example,
# primes 1099511627800 1099511627820
would output
1099511627803
1099511627807
1099511627813
when in fact only the first of those values is prime.

This commit adds strong pseudoprime tests to validate the candidates
which pass the initial sieving stage, using bases of 2, 3, 5, 7, 11,
13, 17, 19, and 23.  Thanks to papers from C. Pomerance, J.L. Selfridge,
and S.S. Wagstaff, Jr.; G. Jaeschke; and Y. Jiang and Y. Deng, we know
that the smallest value which passes these tests is 3825123056546413051.

At present we do not know how many strong pseudoprime tests are required
to prove primality for values larger than 3825123056546413050, so we
force primes(6) to stop at that point.

Reviewed by:	jmg
Relnotes:	primes(6) now correctly enumerates primes up to
		3825123056546413050
MFC after:	7 days
Sponsored by:	EuroBSDCon devsummit
2014-09-26 09:40:48 +00:00
Warner Losh
3bdf775801 NO_MAN= has been deprecated in favor of MAN= for some time, go ahead
and finish the job. ncurses is now the only Makefile in the tree that
uses it since it wasn't a simple mechanical change, and will be
addressed in a future commit.
2014-04-13 05:21:56 +00:00
Warner Losh
f5144a270d Remove the third clause for the Berkeley parts of games, per the
letter in /COPYRIGHT.
2010-02-15 18:46:02 +00:00
Ruslan Ermilov
e653b48c80 Start the dreaded NOFOO -> NO_FOO conversion.
OK'ed by:	core
2004-12-21 08:47:35 +00:00
Ruslan Ermilov
a35d88931c For variables that are only checked with defined(), don't provide
any fake value.
2004-10-24 15:33:08 +00:00
Jens Schweikhardt
9d5abbddbf Correct typos, mostly s/ a / an / where appropriate. Some whitespace cleanup,
especially in troff files.
2003-01-01 18:49:04 +00:00
Tony Finch
d34adef8a0 Last commit was slightly hasty: #include <string.h> is required on
-CURRENT to be WARNS-safe (but not -STABLE for some reason)
2002-10-09 20:42:40 +00:00
Tony Finch
ad8222269e Kill obsolete #include <memory.h> which I didn't spot earlier because
it's still in the NetBSD version.
2002-10-09 20:30:57 +00:00
Tony Finch
9a171f4fc4 Style fixes to: #include ordering; use const and static; ANSI functions;
various usage synopses; bogus and/or unnecessary casting; exit values;
use LINE_MAX instead of magic numbers; declare extern variables in a
header; add $FreeBSD$ where missing.

Reviewed by:    markm, obrien
Obtained from:  NetBSD | fanf
2002-10-09 19:38:55 +00:00
Bill Fumerola
a48e6c8736 staticize functions and variables
change function declarations to ANSI
change a variable that stores sizeof() values to size_t
use return to escape the end of main(), not exit(3)
2002-02-21 18:13:31 +00:00
Bill Fumerola
a30946043b use the typedef 'ubig' to declare pr_limit, not what ubig is typedef'd
to be.

PR:		misc/35181
Submitted by:	Stefan Farfeleder <e0026813@stud3.tuwien.ac.at>
MFC after:	3 days
2002-02-21 17:33:56 +00:00
Warner Losh
ad64363769 Remove __P
Remove __STDC__ (which means we now use stdarg rather than vararg)
Remove register
Remove main prototype
2002-02-18 05:15:19 +00:00
Peter Pentchev
ca33a43ede Fix a typo. While 'iff' might make sense in a mathematics-related text,
'if and only iff' does not.

PR:		33242
Submitted by:	Eric Yu <ericyu@mail2000.com.tw>
2001-12-27 13:33:10 +00:00
Bill Fumerola
7b216475bf copyright/sccsid/rcsid cleanup. 1999-11-30 03:50:02 +00:00
Bill Fumerola
727bf60729 Sync our register usage with NetBSD's (non-)usage. 1999-11-16 02:58:06 +00:00
Bill Fumerola
879099e556 Add $FreeBSD$ 1999-11-16 02:45:03 +00:00
Warner Losh
63f8ec6b73 Fix printf errors in the hflag case.
Fix old bug with bogus casing to (long).
Document the true limits of factor on 64-bit architectures.

Submitted by: bde
1999-01-06 19:46:56 +00:00
Warner Losh
be47d628ca added -h flag to allow for hexidecimal output.
Use '0' for base rather than 10 to allow for more flexible input bases.

Inspired by changes in PR 7402, but mostly redone by me to get past
bde filter.

Submitted by: Timo J. Rinne
PR: 7402
1999-01-06 08:14:26 +00:00
Poul-Henning Kamp
7885089c3c Revert the last commit, it made the Bruce filter flip:
PR7402 was even less suitable for committing almost verbatim than at
first appearance.  Rev.1.9 of primes.c has at least the following defects.

- no update for man page.
- no update for usage string.
- blowing away of a previous commit to change EOF to -1 in getopt() test.
- blowing away of a previous commit to fix printf format errors.
- new printf format errors.
- one gratuitous ANSIism.
- two style bugs.
- ... and a partition in a pear tree.

PR:		7402
1998-08-09 10:36:25 +00:00
Poul-Henning Kamp
fb57be16af Games primes and factor don't understand hexadecimals.
This would make these `games' somewhat useful tools.

PR:		7402
Reviewed by:	phk
Submitted by:	Timo J. Rinne <tri@iki.fi>
1998-08-07 06:32:45 +00:00
Bruce Evans
e13d2860b1 Fixed printf format errors. 1998-06-30 19:10:49 +00:00
John Birrell
a217dc6fbc Cast pointers to longs, not ints.
Hopefully that's the last of the 64-bit cleaning of src/games. That is,
without adding -Wall to the compiler flags. That's not a pretty sight.
1998-05-09 11:33:22 +00:00
Jordan K. Hubbard
01f228ffbe Wargh! Who went and changed all the getopt() comparisons from -1 to
EOF?  The getopt(3) manpage clearly states that the return value is *-1*,
not EOF!  Besides, getopt(3) isn't reading from a file. :)

Noticed-while:	merging to 2.2 (where this is correct).
1998-03-01 05:10:28 +00:00
Andrey A. Chernov
663d61b5eb Remove so-called revoke, this game never installed sguid 1997-09-01 11:40:18 +00:00
Eivind Eklund
34a13bf4cb Change games from setuid games to setgid games.
Reviewed by:	maybe@yes.no
Obtained from:	OpenBSD (mostly deraadt@openbsd.org)
1997-09-01 00:34:51 +00:00
Peter Wemm
bdb5b1dbdc Merge from Lite2 (oops, nearly forgot these ones) 1997-03-11 17:25:32 +00:00
Rodney W. Grimes
010f5413b5 Remove trailing whitespace. 1995-05-30 03:37:36 +00:00
Jordan K. Hubbard
554eb505f8 Bring in the 4.4 Lite games directory, modulo man page changes and segregation
of the x11 based games.  I'm not going to tag the originals with bsd_44_lite
and do this in two stages since it's just not worth it for this collection,
and I've got directory renames to deal with that way.  Bleah.
Submitted by:	jkh
1994-09-04 04:03:31 +00:00