pgcd(): avoid infinite loop if the first GCD candidate coincides with GCD