summaryrefslogtreecommitdiffstats
path: root/primes/primes.6
diff options
context:
space:
mode:
authorast <ast@NetBSD.org>2014-10-02 21:36:37 +0000
committerast <ast@NetBSD.org>2014-10-02 21:36:37 +0000
commit2eb43769534644ef8af78e6a1fa70c755d41200b (patch)
treef39dbbb28c3e53e18a61d031583f9cccc1c89416 /primes/primes.6
parentd43706be7b336fd46d5a93d300182a17193f5544 (diff)
downloadbsdgames-darwin-2eb43769534644ef8af78e6a1fa70c755d41200b.tar.gz
bsdgames-darwin-2eb43769534644ef8af78e6a1fa70c755d41200b.tar.zst
bsdgames-darwin-2eb43769534644ef8af78e6a1fa70c755d41200b.zip
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
Diffstat (limited to 'primes/primes.6')
-rw-r--r--primes/primes.642
1 files changed, 30 insertions, 12 deletions
diff --git a/primes/primes.6 b/primes/primes.6
index 9499398f..6928fe66 100644
--- a/primes/primes.6
+++ b/primes/primes.6
@@ -1,4 +1,4 @@
-.\" $NetBSD: primes.6,v 1.3 2008/02/03 03:29:17 wiz Exp $
+.\" $NetBSD: primes.6,v 1.4 2014/10/02 21:36:37 ast Exp $
.\"
.\" Copyright (c) 1989, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -33,9 +33,7 @@
.\" @(#)factor.6 8.1 (Berkeley) 5/31/93
.\"
.\"
-.\" By: Landon Curt Noll chongo@toad.com, ...!{sun,tolsoft}!hoptoad!chongo
-.\"
-.\" chongo <for a good prime call: 391581 * 2^216193 - 1> /\oo/\
+.\" By Landon Curt Noll, http://www.isthe.com/chongo/index.html /\oo/\
.\"
.Dd February 3, 2008
.Dt PRIMES 6
@@ -46,6 +44,7 @@
.Sh SYNOPSIS
.Nm primes
.Op Fl d
+.Op Fl h
.Op Ar start Op Ar stop
.Sh DESCRIPTION
The
@@ -61,18 +60,18 @@ value must be at least 0 and not greater than
.Ar stop .
The
.Ar stop
-value must not be greater than 4294967295.
+value must not be greater than 3825123056546413050.
The default value of
.Ar stop
-is 4294967295.
+is 3825123056546413050.
.Pp
When the
.Nm
utility is invoked with no arguments,
.Ar start
-is read from standard input.
+is read from standard input and
.Ar stop
-is taken to be 4294967295.
+is taken to be 3825123056546413050.
The
.Ar start
value may be preceded by a single
@@ -81,15 +80,34 @@ The
.Ar start
value is terminated by a non-digit character (such as a newline).
The input line must not be longer than 255 characters.
+.Pp
When given the
.Fl d
argument,
.Nm
prints the difference between the current and the previous prime.
+.Pp
+When given the
+.Fl h
+argument,
+.Nm
+prints the prime numbers in hexadecimal.
.Sh DIAGNOSTICS
Out of range or invalid input results in
-an appropriate error message
-being written to standard error.
-.Sh BUGS
+an appropriate error message to standard error.
+.Sh AUTHORS
+Originally by
+.An Landon Curt Noll ,
+extended to some 64-bit primes by
+.An Colin Percival .
+.Sh CAVEATS
+This
.Nm
-won't get you a world record.
+program won't get you a world record.
+.Pp
+The program is not able to list primes between
+3825123056546413050 and 18446744073709551615 (2^64
+- 1) as it relies on strong pseudoprime tests after
+sieving, and it is yet unknown how many of those
+tests are needed to prove primality for integers
+larger than 3825123056546413050.