Re-use gmx_greatest_common_divisor()

Change-Id: Iee3a7b3bc339639360eed3498769efe64dd7dbf8