Add Greatest Common Divisor helper function

Add Greatest Common Divisor helper function
to be used by several modules later on.