20983, "damianmoz", "Generic gcd", "2022-11-04T15:33:35Z"
As somebody who likes 32-bit integers and occasionally dabbles in 16-bit integers, can I suggest the more generic and slightly tighter gcd(a,b) as a replacement within Math.chpl.
proc gcd(in a : int(?w), in b : int(w))
{
(a, b) = (abs(a), abs(b));
while b != 0 do
{
(a, b) = (b, a % b);
}
return a;
}
It is neither faster nor slower for int(64).