calculation of greatest common divisor added