program properly calculates the GCD