factor bug
[email protected] (Dave Nunn) Wed, 16 Apr 2014 20:08:15 -0400
| Newsgroups | perl.ppt |
|---|---|
| Message-ID | <CAB6ToBg-+=83tm1V2o0955=_w8VzJL-ST08NpFf-GQbQR8becw@mail.gmail.com> |
--047d7bd760c26b0d5104f731d413 Content-Type: text/plain; charset=UTF-8 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 [email protected] --047d7bd760c26b0d5104f731d413 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Hello --<div><br></div><div>Not sure anyone is tracking th= is, but the factor program at:</div><div><a href=3D"http://cpansearch.perl.= org/src/CWEST/ppt-0.14/html/commands/factor/factor.feinberg">http://cpansea= rch.perl.org/src/CWEST/ppt-0.14/html/commands/factor/factor.feinberg</a><br= > </div><div>does indeed have a bug. Try:</div><div>factor 3599</div><div>and= it will report this as prime, though 59*61 =3D=3D 3599.</div><div>The bug = is presumably in the line:</div><div>$max-- if $max %2; =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # Make the max odd<br> </div><div>as this does NOT force $max to be odd, but rather even.</div><di= v>Not sure if the preferred rectification is:</div><div>$max++ unless $max = %2;</div><div>-or-</div><div>$max-- unless $max %2;</div><div>though either= works for the specific case of 3599.</div> <div><br></div><div>Best wishes,<br><div dir=3D"ltr"><div>-- David S. Nunn,= PhD</div><div><a href=3D"mailto:[email protected]" target=3D"_blank">= [email protected]</a>=C2=A0</div></div> </div></div> --047d7bd760c26b0d5104f731d413--