Quantcast
Channel: perl.ppt
Viewing all articles
Browse latest Browse all 80

factor bug (2 messages)

0
0
Hello --

Not sure anyone is tracking this, but the factor program at:
http://cpansearch.perl.org/src/CWEST/ppt-0.14/html/commands/factor/factor.feinberg
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;
-or-
$max-- unless $max %2;
though either works for the specific case of 3599.

Best wishes,
-- David S. Nunn, PhD
david.s.nunn@gmail.com

Viewing all articles
Browse latest Browse all 80

Latest Images

Trending Articles





Latest Images