How to get the greatest common factor