develooper Front page | perl.ppt | Postings from April 2014

factor bug

Thread Next
Dave Nunn
April 19, 2014 06:44
factor bug
Message ID:
Hello --

Not sure anyone is tracking this, but the factor program at:
does indeed have a bug. Try:
factor 3599
and it will report this as prime, though 59*61 == 3599.
The bug is presumably in the line:
$max-- if $max %2;                   # Make the max odd
as this does NOT force $max to be odd, but rather even.
Not sure if the preferred rectification is:
$max++ unless $max %2;
$max-- unless $max %2;
though either works for the specific case of 3599.

Best wishes,
-- David S. Nunn, PhD

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About