Subject: Bug in "factor" (fwd)
To: None <current-users@NetBSD.ORG>
From: Brad Salai <>
List: current-users
Date: 02/21/1998 09:25:30
Newsgroups: comp.unix.bsd.netbsd.misc
Subject: Bug in "factor"
Date: 17 Feb 1998 21:20:17 GMT
Organization: Apache Point Observatory
Lines: 31
Distribution: world
Message-ID: <6ccuuh$po1@bubba.NMSU.Edu>
Keywords: bug factor
Xref: comp.unix.bsd.netbsd.misc:8124

Let me preface by saying I'm not a Net-BSD user or reader of this newsgroup.
I downloaded the "factor" program from

It is version

/*	$NetBSD: factor.c,v 1.4 1997/12/20 23:47:02 cjs Exp $ */ 

and tried to compile it and use it under Solaris 5.5.  I found that it
gives erroneous results for odd perfect squares (25, 49, etc.).  The
bug fix is in the routine "build_primes".  The line

	for (pc = primes[num_primes-1]; pc < 46345 && pc*pc < max; pc+=2) { */

should be

	for (pc = primes[num_primes-1]; pc < 46345 && pc*pc <= max; pc+=2) {

I tried to find an E-mail address for the author, Philip A. Nelson of
iermont Information Systems, but had no success.  Would someone see
that this patch gets applied?

Thanks in advance,


P.S.  This program is entirely different from the program in the directory