Updated getGreatestCommonDenominator() method