I will fix it when I get in to work but the answer is simple. gcd checks for 0 but not for negative as it is using numbers from fabs(). The problem is just an overflow problem converting to int from double. Easy to fix, but I ought to go through the data Kish sent to double check. John Forrest