summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--games/factor/factor.612
-rw-r--r--games/factor/factor.c10
-rw-r--r--games/primes/primes.c4
3 files changed, 13 insertions, 13 deletions
diff --git a/games/factor/factor.6 b/games/factor/factor.6
index 4844780..316abdd 100644
--- a/games/factor/factor.6
+++ b/games/factor/factor.6
@@ -52,12 +52,12 @@ factor, primes \- factor a number, generate primes
.SH DESCRIPTION
The
.I factor
-utility will factor integers between 0 and 4294967295 inclusive.
-When a number is factored, it is printed, followed by a ``:'',
-and the list of factors on a single line.
-Factors are listed in ascending order, and are preceded by a space.
-If a factor divides a value more than once, it will be printed
-more than once.
+utility will factor integers between 0 and ULONG_MAX (4294967295 on 32
+bit architectures, 18446744073709551615 on 64 bit ones), inclusive.
+When a number is factored, it is printed, followed by a ``:'', and the
+list of factors on a single line. Factors are listed in ascending
+order, and are preceded by a space. If a factor divides a value more
+than once, it will be printed more than once.
.PP
When
.I factor
diff --git a/games/factor/factor.c b/games/factor/factor.c
index c5fdbaa..aa64dd5 100644
--- a/games/factor/factor.c
+++ b/games/factor/factor.c
@@ -173,7 +173,7 @@ pr_fact(val)
}
/* Factor value. */
- (void)printf(hflag ? "0x%x:" : "%lu:", val);
+ (void)printf(hflag ? "0x%lx:" : "%lu:", val);
for (fact = &prime[0]; val > 1; ++fact) {
/* Look for the smallest factor. */
do {
@@ -183,15 +183,15 @@ pr_fact(val)
/* Watch for primes larger than the table. */
if (fact > pr_limit) {
- (void)printf(hflag ? " 0x%x" : " %lu", val);
+ (void)printf(hflag ? " 0x%lx" : " %lu", val);
break;
}
/* Divide factor out until none are left. */
do {
- (void)printf(hflag ? " 0x%x" : " %lu", *fact);
- val /= (long)*fact;
- } while ((val % (long)*fact) == 0);
+ (void)printf(hflag ? " 0x%lx" : " %lu", *fact);
+ val /= *fact;
+ } while ((val % *fact) == 0);
/* Let the user know we're doing something. */
(void)fflush(stdout);
diff --git a/games/primes/primes.c b/games/primes/primes.c
index f204b37..7211de5 100644
--- a/games/primes/primes.c
+++ b/games/primes/primes.c
@@ -261,7 +261,7 @@ primes(start, stop)
for (p = &prime[0], factor = prime[0];
factor < stop && p <= pr_limit; factor = *(++p)) {
if (factor >= start) {
- printf(hflag ? "0x%x\n" : "%lu\n", factor);
+ printf(hflag ? "0x%lx\n" : "%lu\n", factor);
}
}
/* return early if we are done */
@@ -324,7 +324,7 @@ primes(start, stop)
*/
for (q = table; q < tab_lim; ++q, start+=2) {
if (*q) {
- printf(hflag ? "0x%x\n" : "%lu\n", start);
+ printf(hflag ? "0x%lx\n" : "%lu\n", start);
}
}
}
OpenPOWER on IntegriCloud