Adds function for calculating GCD.