Subject: Bug in "factor" (fwd)
To: None <current-users@NetBSD.ORG>
From: Brad Salai <bsalai@law.roc.servtech.com>
List: current-users
Date: 02/21/1998 09:25:30
Path: post.servtech.com!newsfeeder.servtech.com!news.infi.net!news.vt.edu!solaris.cc.vt.edu!newsrelay.netins.net!uunet!in2.uu.net!news.mathworks.com!nntprelay.mathworks.com!news.eecs.umich.edu!newshub.tc.umn.edu!lynx.unm.edu!bubba.NMSU.Edu!nmsu.edu!brinkmann
From: brinkmann@nmsu.edu
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>
NNTP-Posting-Host: dilbert.apo.nmsu.edu
Keywords: bug factor
Xref: post.servtech.com 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

ftp://ftp.digital.com/pub/BSD/NetBSD/NetBSD-current/src/distrib/utils/sysinst/factor.c

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,

Jon

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

ftp://ftp.digital.com/pub/BSD/NetBSD/NetBSD-current/src/games/factor/