Perl Monk, Perl Meditation | |
PerlMonks |
Re: greatest common factorby TheAmigo (Initiate) |
on Apr 16, 2015 at 19:51 UTC ( [id://1123659]=note: print w/replies, xml ) | Need Help?? |
I found this function and it seemed reasonable, but some of my users reported that I was somtimes returning the wrong sign.
Turns out that the function above has inconsistent behavior on negative numbers:
when they should really both be 5. 14 years late, but here's a fix. I changed my code so that gcf() ends with return abs $x;
In Section
Cool Uses for Perl
|
|